yum 安裝的mysql 重置密碼

  1. 不小心忘了mysql密碼,系統是rhel5.5 mysql版本5.0.77,yum安裝的,簡單記錄下恢復過程。
  2.  
  3. [root@localhost ~]# /etc/init.d/mysqld stop  
  4. Stopping MySQL:                                            [  OK ] 
  5. [root@localhost ~]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking & 
  6.  
  7. [root@localhost ~]# mysql 
  8. Welcome to the MySQL monitor.  Commands end with ; or \g. 
  9. Your MySQL connection id is 1 
  10. Server version: 5.0.77 Source distribution 
  11.  
  12. Type 'help;' or '\h' for help. Type '\c' to clear the buffer. 
  13.  
  14. mysql> show databases; 
  15. +--------------------+ 
  16. | Database           | 
  17. +--------------------+ 
  18. | information_schema |  
  19. | demo               |  
  20. | mysql              |  
  21. | ndodb              |  
  22. | webdns             |  
  23. +--------------------+ 
  24. 5 rows in set (0.03 sec) 
  25.  
  26. mysql> use mysql 
  27. Reading table information for completion of table and column names 
  28. You can turn off this feature to get a quicker startup with -A 
  29.  
  30. Database changed 
  31. mysql> show tables; 
  32. +---------------------------+ 
  33. | Tables_in_mysql           | 
  34. +---------------------------+ 
  35. | columns_priv              |  
  36. | db                        |  
  37. | func                      |  
  38. | help_category             |  
  39. | help_keyword              |  
  40. | help_relation             |  
  41. | help_topic                |  
  42. | host                      |  
  43. | proc                      |  
  44. | procs_priv                |  
  45. | tables_priv               |  
  46. | time_zone                 |  
  47. | time_zone_leap_second     |  
  48. | time_zone_name            |  
  49. | time_zone_transition      |  
  50. | time_zone_transition_type |  
  51. | user                      |  
  52. +---------------------------+ 
  53. 17 rows in set (0.00 sec) 
  54.  
  55. mysql> UPDATE user SET Password=PASSWORD('123456') where USER='root';            
  56. Query OK, 3 rows affected (0.00 sec) 
  57. Rows matched: 3  Changed: 3  Warnings: 0 
  58.  
  59. mysql> FLUSH PRIVILEGES; 
  60. Query OK, 0 rows affected (0.00 sec) 
  61.  
  62. mysql> QUIT 
  63. Bye 
  64. [root@localhost ~]# /etc/init.d/mysqld restart 
  65. Starting MySQL:                                            [  OK  ] 
  66.  
  67. [root@localhost ~]# mysql -uroot -p123456 
  68. Welcome to the MySQL monitor.  Commands end with ; or \g. 
  69. Your MySQL connection id is 10 
  70. Server version: 5.0.77 Source distribution 
  71.  
  72. Type 'help;' or '\h' for help. Type '\c' to clear the buffer. 
  73.  
  74. mysql> 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章