Config file changes are required to enable connections via localhost.
To connect through remote IPs, Login as a “root” user and run the below queries in mysql.
CREATEUSER'username'@'localhost'IDENTIFIEDBY'password';GRANTALLPRIVILEGESON*.*TO'username'@'localhost'WITHGRANTOPTION;CREATEUSER'username'@'%'IDENTIFIEDBY'password';GRANTALLPRIVILEGESON*.*TO'username'@'%'WITHGRANTOPTION;FLUSH PRIVILEGES;
This will create a new user that is accessible on localhost as well as from remote IPs.
Also comment the below line from your my.cnf file located in /etc/mysql/my.cnf
bind-address=127.0.0.1
Restart your mysql using
sudo service mysql restart
Now you should be able to connect remotely to your mysql.
Source: grant remote access of MySQL database from any IP address – Stack Overflow
grant remote access of MySQL database from any IP address was last modified: May 18th, 2018 by