1: Log in to the mysql database :
Log in to mysql with mysql -uroot -p, and then use the following methods to enable remote access:
mysql>use mysql;
mysql>update user set host = '%' where user = 'root';
mysql> flush privileges; //Refresh MySQL's system privilege related table
(An error will be reported when executing update user set host = '%' where user = 'root';
ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY',
But check the host=127.0.0.1 in the user table, the data of user=root has been changed to host=%, so don’t pay attention to this error
)
2: Set the mysql configuration file
/etc/mysql/my.cnf
to find bind-address =127.0.0.1 and modify it to:
bind-address =0.0.0.0
restart mysql: /etc/init.d/mysql restart;