Modify the permission that mysql allows the host to access. mysql allows the host permission.
Enable mysql Remote Access Permissions
By default, mysql users do not have the permission for remote access. Therefore, when the program is not on the same server as the database, we need to enable the remote access permission for mysql.
There are two mainstream Methods: table modification and authorization.
Relatively speaking, it is easier to change the table method. individuals prefer to use this method. Therefore, only the alter table method is attached here.
1. log on to mysql
Mysql-u root-p
2. Modify the user table of the mysql database and change the host item from localhost to %. % This indicates that access from any host is allowed. If only one ip address is allowed, you can change it to the corresponding ip address. For example, you can change localhost to 192.168.1.123, this means that only the ip address 192.168.1.123 of the LAN can remotely access mysql.
Mysql> use mysql;
Mysql> update user set host = '%' where user = 'root ';
Mysql> select host, user from user;
Mysql> flush privileges;
Open firewall port 3306