Remote access to MySQL
4 Replies
MySQL reference manualServer Administration
Also, look into using SSH for the MySQL connection. At the very least use the '-C' option when connecting from a remote address.
1) Make sure your iptables / firewall is allowing external access to TCP port 3306
2) Make sure your my.cnf [mysqld] section is using TCP (port 3306) instead of / along side a socket file.
3) Make sure your my.cnf is using bind-address to your external address
4) Create a user for an external connection, e.g.
CREATE USER external@'%' IDENTIFIED BY 'somepassword';
You can also specify a specific domain or IP addr you're connecting from, e.g.
CREATE USER external@'otherdomain.com' IDENTIFIED BY 'somepassword';
5) Make sure you choke down the GRANT for this user!!
GRANT SELECT,INSERT,DELETE ON yourdb.* TO external@'%';
I think that's about it. Restart mysqld (/etc/init.d/mysql restart).
Just make sure you're bound to 127.0.0.1, and that your connection script retries on disconnect, and that it's part of startup.
Guide from the libary