Cloud VPS [Ubuntu]: How to Configure MySQL for Remote Access

For security reasons, when your Linux VPS server is released MySQL is configured with a randomized root password and remote connections are disabled. Please follow the steps below to allow MySQL through your firewall, configure MySQL to listen on your public network interface, and reset the root password.

Allow MySQL Connections through the firewall:

sudo ufw allow mysql

Stop MySQL:

sudo /etc/init.d/mysql stop

Edit the MySQL Configuration:

sudo nano /etc/mysql/my.cnf
Set the bind address to For example:
bind-address            =

Reset the MySQL root password:

sudo mysqld --skip-grant-tables &
mysql -u root mysql
UPDATE user SET Password=PASSWORD('YOURNEWPASSWORD') WHERE User='root'; flush privileges; exit;

Restart MySQL
sudo killall mysqld
sudo /etc/init.d/mysql restart

You can now test remote connections using a MySQL Client, telnet, or a development language such as PHP. 

Add Feedback