修改配置文件:
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
,保存并退出。 - 再次重启