To add mysql user with remote access to the database you have to:
- bind mysql service to external IP address on the server
- add mysql user for remote connection
- grant user permissions to access the database
In order to connect remotely you have to have MySQL bind port 3306 to your server’s external IP.
#Replace xxx with your IP Address bind-address = xxx.xxx.xxx.xxx
Restart mysql as you change config. If you don’t have firewall enabled, you should have access to mysql service from external clients now.
Now you have to have created the user in both localhost and ‘%’ wildcard and grant permissions on all DB’s as such . Open mysql and run commands:
CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'mypass'; CREATE USER 'myuser'@'%' IDENTIFIED BY 'mypass';
GRANT ALL ON *.* TO 'myuser'@'localhost'; GRANT ALL ON *.* TO 'myuser'@'%';
This will let myuser access all databases from server as well from external sources. Depending on your OS you may have to open port 3306 to allow remote connections. If it’s your case – look for firewall (iptables in Linux OSes) configuration