Issue & Solution During Connecting to MySQL Remotely

MySQL doesn't allow remote connection in default setting and we need to to separate setting.

To access MySQL server remotely, firstly we need to configure the MySQL configuretion file by running

nano /etc/mysql/my.cnf

and comment the line

bind-address =127.0.0.1
by adding "#".

This is to permit the IPs other than localhost to connect the MySQL server.

Then we need to grant the remote access to users within MySQL. For example, I want to grant the "root" user (password is '123456') remote access from any IP address.

GRANT ALL PRIVILEGES ON *.* TO root@'%' IDENTIFIED BY '123456’;
You can also sepcify the IP to which you want to grant access, let's say '123.123.123.123', by
GRANT ALL PRIVILEGES ON *.* TO root@'123.123.123.123' IDENTIFIED BY '123456’;
Please note that if you're using amazon EC2, you also need to edit the “security group”. In the "Inbound" section, add one more rule with type “MYSQL/Aurora” and source “0.0.0.0/0” (that is “Anywhere").