So, once you’re all set up and running, you may want to give users access from the outside world. This is clearly an entry point for hackers and script kiddies, so be sure that you want to open up your database to the net.
I believe that, out of the box, MySQL is bound to the localhost IP address (127.0.0.1) so that will need changing first of all.
Edit my.cnf and find the line ‘bind-address’:
Now change this to allow access from other IP addresses, if you want *all* access then change it to 0.0.0.0 or comment it out completely. You can only set it to one IP address, or all. (as shown)
Ensure your users can connect from the IP address you set it to:
GRANT <privileges> TO 'user'@'<ipaddress> IDENTIFIED BY '<password>';
GRANT SELECT,INSERT,DELETE,UPDATE TO 'user1'@'18.104.22.168' IDENTIFIED BY 'letm3in';
Or, to all this user access from anywhere:
GRANT SELECT,INSERT,DELETE,UPDATE TO 'user1'@'%' IDENTIFIED BY 'letm3in';
Finally, restart the server and you’re done.
Let me just re-iterate, ensure you will be able to connect to the database from anywhere before restarting the server. Don’t blame me if you lock down a remote server with no access to it!