1. [root@localhost bin]# ./mysql -uroot -p12345  

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)  


进入 mysql 安装的目录  


cd  /usr/local/mysql/bin


  1. [root@localhost bin]# ./mysqld_safe --user=root --skip-grant-tables --skip-networking &  

  2. [1] 3818  

  3. [root@localhost bin]# 111105 07:30:32 mysqld_safe Logging to '/usr/local/mysql/var/localhost.localdomain.err'.  

  4. 111105 07:30:32 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/var  

  5. # ./mysql -uroot mysql  

  6. Welcome to the MySQL monitor.  Commands end with ; or \g.  

  7. Your MySQL connection id is 1  

  8. Server version: 5.1.48-log Source distribution  

  9. mysql> update user set password=password('12345') where user='root' ;  

  10. Query OK, 3 rows affected (0.05 sec)  

  11. Rows matched: 3  Changed: 3  Warnings: 0    

  12. mysql> flush privileges;  

  13. Query OK, 0 rows affected (0.00 sec)  

  14. mysql> quit  

  15. Bye