終端命令行可正常登入 MySQL、建庫建表,但 Navicat、MySQL Workbench 等 GUI 客戶端連接報錯,嘗試多個客戶端均失敗。
mysql.server status。lsof -i :3306 或在 MySQL 客戶端執行 SHOW VARIABLES LIKE 'port';。在客戶端新建連接時,將 Port 設置為實際端口(如 3307),Host 保持 127.0.0.1 或 localhost。
編輯 /etc/my.cnf 或 /usr/local/etc/my.cnf:
[mysqld]
port = 3306
重啟服務:mysql.server restart。
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password'; FLUSH PRIVILEGES;。caching_sha2_password 導致舊版客戶端不兼容,需改用 mysql_native_password 或升級客戶端。