General
How To: Enable Remote MySQL Connections on Ubuntu Server
Posted on .1. Identify public IP address:
$ curl ident.me
2. Edit /etc/mysql/my.cnf, replacing the value for bind-address, usually 127.0.0.1 with your public IP address derived above:
bind-address = 127.0.0.1
3. Type the following to enter the MySQL shell and provide your password:
mysql -u root -p
4. Grant remote access to the desired MySQL user with the following command, replacing ‘root’ with the desired user and ‘your-password’ with the user’s password:
mysql> GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY 'your-password';
mysql> FLUSH PRIVILEGES;
5. Restart MySQL and verify it’s listening:
sudo service mysql restart && netstat -plnt | grep 'mysql'
Your output should look similar to this:
mysql stop/waiting
mysql start/running, process 16866
tcp 0 0 4.23.22.81:3306 0.0.0.0:* LISTEN 16866/mysqld
6. You’re done. Now try connecting from a remote machine:
mysql -h 4.23.22.81 -u root -p
7. Profit!