How to allow all clients access to remote MySQL server? [closed]

So I followed this guide to gain remote access to a MySQL server for my laptop. However, my IP changes and I want to be able to access the server outside my network. How can I allow any client IP to access it if they have the password?

Here are the main commands that I’m referring to:

mysql> use mysql
mysql> GRANT ALL ON *.* to root@'client.ip.goes.here' IDENTIFIED BY 'your-root-password'; 
mysql> FLUSH PRIVILEGES;

Any way to do this?

Answer

I’ve had similar problems in the past. My solution was to tunnel the MySQL connect through a SSH tunnel. It’s quick & dirty but effective. Firstly, MySQL is bound to 127.0.0.1 using the my.cnf &

bind-address = 127.0.0.1

This means MySQL is no longer available in the net. It won’t answer any more queries unless they come from the local host. After that I install & configure openssh. I won’t discuss that here, everybody has his own ideas on what’s best. Just make sure that SSH is available in your net segment (or wherever you need it). On the Client I start a SSH tunnel.

MySQLClient:~# ssh -f -L 3306:127.0.0.1:3306 mysqluser@MySQLServer -N

Now MySQL is reachable over my client. Simply

mysql -u root -p -h 127.0.0.1

I use this quite a lot & it works.

Hope it was helpful.

Attribution
Source : Link , Question Author : kibowki , Answer Author : Eamonn Travers

Leave a Comment