-1

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?

Andrew Schulman
  • 8,811
  • 21
  • 32
  • 47
kibowki
  • 109
  • 2
  • Hi. Allowing that kind of access to MySQL over the INET is not a good idea. Have you considered using a simple SSH tunnel or even better a VPN? – Eamonn Travers Nov 08 '14 at 09:55
  • Can I ask why you want to allow all IPs? That could be potentially dangerous depending on the use case. – Mike B Nov 09 '14 at 07:12

2 Answers2

2

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.

Eamonn Travers
  • 614
  • 4
  • 11
-1

GRANT ALL ON . to root@'%' IDENTIFIED BY 'your-root-password';

It's a bit ugly though to give full access just with a password. I would suggest you use SSL keys for root logins, if you really need full remote access.

richardb
  • 1,256
  • 9
  • 14