-
修改配置文件
vim /etc/my.cnf
-
在
[mysqld]
下增加一行#或者:--skip-grant-tables,兩者區別是有時兩個橫線會導致服務無法重啓需要測試應當添加否。 skip-grant-tables
-
重啓
systemctl restart mysqld
-
無密碼登錄
UPDATE mysql.`user` SET `authentication_string`=PASSWORD("your_password") WHERE USER="root";
-
注掉
[mysqld]
中skip-grant-tables
的配置 -
重啓
systemctl restart mysqld
參考