Sunday 7 August 2016

MySQLTips: Raspberry Pi MySQL Workbench Refusing to Accept Remote Connections

Ever had this problem when you set up a MySQL database on your Raspberry Pi and you are trying to remotely connect to your database from another client but the connection refuses to establish? This problem to many people seems to be a frustrating problem. However, please do not confuse this article with remote connections from a client outside of your own network. For that, you will have to perform port forwarding (Port: 3306) on your router to enable access from clients outside of your network.

In this article, I will show you a simple fix for this problem! I will be using a Raspberry Pi as my MySQL server and NANO as my text editor. The version of NOOBS I'm using is 1.9.2 and I believe that this article will work for previous versions of the operating system.

Thanks to the following articles for helping solve my problems:

http://serverfault.com/questions/586651/mysql-refuses-to-accept-remote-connections

http://stackoverflow.com/questions/14779104/how-to-allow-remote-connection-to-mysql



Step 1:
$ sudo nano /etc/mysql/my.cnf

Modify the bind-address section under the [mysqld] header from



bind-address = 127.0.0.1

to

bind-address = 0.0.0.0



Step 2:
$ sudo service mysql restart

Step 3:
On your MySQL Workbench on your server, create the following queries:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;

FLUSH PRIVILEGES;

Select on APPLY.

Step 4:
Now you should be able to access your MySQL database remotely from your local clients.