有以下兩種情況: 1、mysql未分配訪問權限 格式:grant 權限 on 數據庫名.表名 用戶@登錄主機 identified by "用戶密碼"; grant select,update,insert,delete on *.* to zhxia@'%' identified by '123456'; 或者所有權限 GRANT ALL PRIVILEGES ON *.* TO zhxia@'%' IDENTIFIED BY '123456'; 接着執行 flush privileges; 使授權生效 最后我們還需要修改mysql的配置文件 sudo vim /etc/mysql/my. cnf 2、my.ini配置中未開啟網絡訪問功能 在舊版本中找到 skip-networking,把它注釋掉就可以了 #skip-networking 在新版本中: # Instead of skip-networking the default is now to listen only on # localhost which is more compatible and is not less secure. 找到 :bind-address = 127.0.0.1 這一行要注釋掉 #bind-address = 127.0.0.1