MySQL 5.7 處理辦法
- 修改 /etc/my.ini 配置文件军熏,增加
skip-grant-tables
配置 - 重啟 mysql 服務(wù)
service mysqld restart
- 無密碼登錄
mysql -u root -p
- 切換 mysql 庫
use mysql
- 修改 root 密碼
update user set authentication_string=password('xxx') where user = 'root';
MySQL 8 處理辦法
- 修改 /etc/my.ini 配置文件凌简,增加
skip-grant-tables
配置 - 重啟 mysql 服務(wù)
service mysqld restart
- 無密碼登錄
mysql -u root -p
- 切換 mysql 庫
use mysql
- 清空 root 賬戶密碼:
update user set authentication_string='' where user = 'root';
- 注釋掉
my.ini
中skip-grant-tables
配置后重啟服務(wù)service mysqld restart
- 修改 root 密碼
alert user 'root'@'localhost' identified by 'xxxx';