Cannot Connect Remotely to a New MySQL Installation

  • Post author:
  • Post category:MySQL

We recently installed MySQL on an Ubuntu box for testing purposes. Setup was done by simply running the following as root.

sudo apt-get install mysql-server

Here’s what we did so we could connect remotely from a Windows 7 box.

1. Run mysql as root and grant root@% access.

# mysql -u root
mysql> grant all on *.* to 'root'@'%' identified by password '';

Here we keep using the default root user with no password.

2. Edit my.cnf and allow MySQL to listen to all network interfaces (not just 127.0.0.1). Restart MySQL for the changes to take effect.

# sudo vi /etc/mysql/my.cnf
bind-address = 0.0.0.0
# sudo service mysql restart

3. Once you can connect, we suggest you add the password. The command looks something like:

mysql> set password for 'root'@'%' = PASSWORD('secret');