1 檢查mySql的運(yùn)性狀態(tài)
service mysqld status
2 停止mySql的運(yùn)性
service mysqld stop
3 修改mysql的配置文件my.conf
添加 skip-grant-tables
vi /etc/my.cnf
4 重啟數(shù)據(jù)庫
service mysqld start
5 進(jìn)入mySql數(shù)據(jù)庫
mysql -u root
6 修改密碼
use mysql;
update mysql.user set authentication_string=password('root_password') where user='root';
root_password替換成你想要的密碼
7 刪掉第三步的配置,并重啟服務(wù)器
mysql -u root -p