錯誤 `Access denied for user 'root'@'192.168.1.102'` 通常因密碼錯誤、權限表損壞或主機匹配失敗導致。本文提供通用的命令行重置方案。
# Windows: my.ini | Linux: /etc/my.cnf
[mysqld]
skip-grant-tables# Windows
net stop mysql && net start mysql
# Linux
systemctl restart mysqldmysql -u root -p
# 直接回車進入
USE mysql;
UPDATE user SET authentication_string=PASSWORD('new_password') WHERE User='root';
FLUSH PRIVILEGES;
EXIT;# 刪除 skip-grant-tables 行
systemctl restart mysqldmysql -u root -pnew_password