MySQL There are many reasons why remote access is not allowed. In addition to the following methods, you also need to check the serverSecurity settings to prohibit access to the 3306 port of the machine.
Solution:
1. Change the table method.
It may be that your account does not allow remote login, only localhost. At this time, as long as you log in to mysql on the localhost computer, change the "host" item in the "user" table in the "mysql" database from "localhost" to "%"
Code As follows:
mysql -u root -pvmwaremysql>use mysql; mysql>update user set host = '%' where user = 'root'; mysql>select host, user from user;
2. Authorization law.
For example, if you want myuser to use mypassword to connect to the mysql server from any host.
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
If you want to allow user myuser from ip Connect to mysql server for host 192.168.1.6 and use mypassword as password
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
FLUSH PRIVILEGES ;
If you want to allow the user myuser to connect to the dk database of the mysql server from the host with ip 192.168.1.6 and use mypassword as the password
GRANT ALL PRIVILEGES ON dk.* TO 'myuser'@'192.168.1.3 ' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
The first method I used, I found it didn't work at first. I checked it on the Internet and executed one less statement mysql>FLUSH RIVILEGES to make the modification effective. That's it
Another method, but I haven't tried it personally. I found it on csdn.net, you can take a look.
Run on the machine where mysql is installed:
1. d:\mysql\bin\>mysql -h localhost -u root //This should be able to enter the MySQL server
2. mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION //Give any host permission to access data
3. mysql>FLUSH PRIVILEGES //The modification takes effect
4.mysql>EXIT //ExitMySQL server
This way you can Others Log in as root on any host!
The above is the detailed content of MySQL does not allow remote access. For more information, please follow other related articles on the PHP Chinese website!