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.
CREATE
USER
'username'
@
'localhost'
IDENTIFIED
BY
'password'
;
GRANT
ALL
PRIVILEGES
ON
*.*
TO
'username'
@
'localhost'
WITH
GRANT
OPTION
;
CREATE
USER
'username'
@
'%'
IDENTIFIED
BY
'password'
;
GRANT
ALL
PRIVILEGES
ON
*.*
TO
'username'
@
'%'
WITH
GRANT
OPTION
;
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