Solve mysqlamp; quot; Accessdeniedforuser bitsCN.com
Solve the problem of mysql "Access denied for user 'root' @ 'IP address '"
In MYSQL, remote software is used to log on to the server, sometimes the following occurs: Access denied for user 'root' @ 'localhost'
This problem occurs mainly because the permission configuration is incorrect.
The solution is as follows:
When you log on to MYSQL using a Linux/unix tty, mysql-u root-p will prompt you to enter the password, enter the correct password, and then log on normally.
Then, at the prompt, run the command: show grants; the following root permission is displayed: grant all privileges on *. * TO 'root' @ 'localhost' identified by password '565491d704013245 'WITH GRANT OPTION
At this time, pay attention to the "@". localhost indicates local login. if you use the remote login software to log on, an error message will appear: access denied for user 'root' @ 'IP address '.. The IP address is the IP address of your remote machine. That is, the server tells you that it is rejected when you log on with an "IP address", because the MYSQL permission settings do not grant you the permission to log on to your IP address. Because the show grants command result just now has already been told, only local login is allowed.
The solution is as follows: at this time, you can try to connect with a blank password. Or you can enter the server on the tty or pts console and run the following command:
Grant all privileges on *. * to 'root' @ '%' with grant option;
This means that the root user can log on to the MYSQL server on all machines (with all permissions ). After executing this command, log on to the client and enter the password.
GRANT ALL PRIVILEGES
1. Change the table. It may be that your account is not allowed to log on remotely, but only on localhost. At this time, you only need to log in to mysql on the computer of localhost, and change the "host" entry in the "user" table in the "mysql" database to "%" from "localhost"
SQL code
1. mysql-u root-pvmwaremysql> use mysql;
2. mysql> update user set host = '%' where user = 'root ';
3. mysql> select host, user from user;
2. authorization method. For example, if you want myuser to use mypassword to connect to the mysql server from any host.
SQL code
1. grant all privileges on *. * TO 'myuser' @ '% 'identified BY 'mypassword'
Grant option;
2. flush privileges;
If you want to allow myuser to connect to the mysql server from a host whose ip address is 192.168.1.6, and use mypassword as the password
SQL code
1. grant all privileges on *. * TO 'myuser' @ '192. 168.1.3 'IDENTIFIED
2. 'mypassword' with grant option;
3. flush privileges;
Grant all privileges on *. * TO 'myuser' @ '192. 168.1.3 'IDENTIFIED
'Mypassword' with grant option;
Flush privileges;
If you want to allow myuser to connect to the dk database of the mysql server from a host with ip address 192.168.1.6, and use mypassword as the password
SQL code
1. grant all privileges on dk. * TO 'myuser' @ '192. 168.1.3 'IDENTIFIED
2. 'mypassword' with grant option;
3. flush privileges;
Grant all privileges on dk. * TO 'myuser' @ '192. 168.1.3 'IDENTIFIED
'Mypassword' with grant option;
Flush privileges;
Note that after authorization, you must flush privileges; otherwise, it cannot take effect immediately.
Another method.
Run the following command on the machine where mysql is installed:
1. d:/mysql/bin/> mysql-h localhost-u root
// You can access the MySQL server.
2. mysql> grant all privileges on *. * TO 'root' @ '%' WITH GRANT OPTION
// Grant data access permissions to any host
3. mysql> FLUSH PRIVILEGES
// The modification takes effect.
4. mysql> EXIT
// Exit the MySQL server
In this way, you can log on to any other host as the root user!
BitsCN.com