修改配置文件:
vi /etc/my.cnf## 修改配置文件 ##[mysqld]
skip - grant - tables## 重啟 ##/etc/init.d/mysqld restart ## 或service mysqld restart## 登錄mysqld -u root -p -h 127.0.0.1
USE mysql; UPDATE user SET Password = password('123456') WHERE User = 'root';FLUSH PRIVILEGES; quit
- 將 MySQL 的登錄設置修改回來,打開
my.cnf
文件, - 刪除剛才添加的?
skip - grant - tables
,保存并退出。 - 再次重啟