My system is Ubuntu6.06. The newly installed mysql always has an error prompt when entering the mysql tool:
# Mysql-uroot-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: <Enter the new password newpassword>
Mysql>
| [Content navigation] |
| Page 1st: mysql "Access denied for user 'root' @ 'localhost'" SOLUTION |
Page 2nd: mysql "Access denied for user 'root' @ 'localhost'" SOLUTION |