1、忘記初始密碼
一、查看初始密碼
#grep 'temporary password' /var/log/mysqld.logmysql
二、使用初始密碼登陸
#mysql -u root -psql
三、修改密碼
mysql> ALTER USER 'root' IDENTIFIED BY 'xxxxxxxxx';
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'xxxxxxxx';數據庫
四、刷新權限表
mysql> flush privileges;ide
五、退出、重啓
mysql> exit
#service mysqld restart rest
2、忘記修改後的密碼ip
檢查mysql是否啓動,若是啓動,關閉mysql
//查看mysql狀態
#ps -ef | grep mysql
#service mysql stopstring
三、啓動mysql,並進入mysql
#service mysqld start
#mysql -u root it
修改密碼
鏈接mysql這個數據庫,修改用戶密碼
mysql> use mysql;
mysql> update mysql.user set authentication_string=password('123456') where user='root';
mysql> flush privileges;
mysql> exitio