Connect to MySQL Database Remotely

By default, access to mysql databases is bounded to the server which is running mysql itself. Hence, if we need to log-in to the mysql console or  need to use a database from a remote server, we need to enable those configs.

Open /etc/mysql/my.cnf file.

    sudo vim /etc/mysql/my.cnf

Then uncomment "bind-address ="

*Note:  if you cannot find bind-address in the my.cnf file, it can be found in /etc/mysql/mysql.conf.d/mysqld.cnf file.

Restart mysql using:
   service mysql restart;

This will allow login in to mysql server form a remote machine. To test this, go to the remote server, and execute the following.
   mysql -u root -p -h <ip_of_the_sever_running_mysql> 

This will open up the mysql console of the remote sql server.

But this will only allow to login in to the mysql server. But here we want to use/access the databses from (a client app in) our remote machine. To enable access to databases, we need to grant access for each database.
    grant all on *.* to <your_username>@<ip_of_server_uses_to_connect> identified by '<your_password>'; 

If you want to allow any ip address to connect to the database, use '%' instead of  <ip_of_server_uses_to_connect>.