Mysql password modification bitsCN.com
ERROR Description: After a user is added to Mysql, the ERROR 1045 (28000): Access denied for user may occur during logon. delete user. if the value of user is NULL, or update NULL to test 1) delete from user where user is NULL 2) update user set user = 'test' where user is NULL. unexpected situation: if the above method does not work and empty users still appear, you can use the graphical user client to delete it.
After the CentOS is reinstalled, it is found that Mysql is always unavailable.
# The mysqladmin create dbname command always returns mysqladmin: connect to server at 'localhost' failed
# Mysql-u root @ localhost
> Create database dbname;
Also, ERROR 1045 (28000): Access denied for user 'root' @ 'localhost' (using password: NO) is returned)
# Mysql-u root-p
Enter password:
ERROR 1045 (28000): Access denied for user 'root' @ 'localhost' (using password: NO)
Use the methods described on the Internet to change the password of the root user:
# Mysqladmin-uroot-p password 'newpassword'
Enter password:
Mysqladmin: connect to server at 'localhost' failed
Error: 'Access denied for user' root' @ 'localhost' (using password: YES )'
Now I have found the solution as follows (please test method 3 first, thank you !) :
Method 1:
#/Etc/init. d/mysql stop
# Mysqld_safe -- user = mysql -- skip-grant-tables -- skip-networking &
# Mysql-u root mysql
Mysql> UPDATE user SET Password = PASSWORD ('newpassword') where USER = 'root ';
Mysql> flush privileges;
Mysql> quit
#/Etc/init. d/mysql restart
# Mysql-uroot-p
Enter password: <输入新设的密码newpassword>
Mysql>
Method 2:
Directly use the username and password provided in the [client] section of the/etc/mysql/debian. cnf file:
# Mysql-udebian-sys-maint-p
Enter password: <输入[client]节的密码>
Mysql> UPDATE user SET Password = PASSWORD ('newpassword') where USER = 'root ';
Mysql> flush privileges;
Mysql> quit
# Mysql-uroot-p
Enter password: <输入新设的密码newpassword>
Mysql>
Method 3:
I have not tested this method, because the default password of my root user has been modified by me. if you have time to test it, let me know the result. thank you!
# Mysql-uroot-p
Enter password: <输入 etc mysql debian.cnf文件中[client]节提供的密码>
At this point, many problems have been solved!
Detailed source reference: http://www.bitsCN.com/linuxjishu/10981.html
BitsCN.com