mysql修改root密码

MySQL root密码忘记的解决
1.先停掉mysql
# sudo /etc/init.d/mysql stop
2.以--skip-grant-table 的參數啟動mysql
# sudo mysqld_safe --skip-grant-table&
3. 更改root 密码为:123456
# mysql mysql
mysql> UPDATE user SET password=password('123456') WHERE user='root';
mysql> FLUSH PRIVILEGES;
mysql> exit
4.停掉mysql再重跑
sudo killall mysqld
#/sudo /etc/init.d/mysql start
#sudo  mysql -u root -p
Enter password:
OK啦,嘿嘿~~

你可能感兴趣的:(mysql修改root密码)