2
我想使用SSH隧道連接到遠程主機上的MySQL數據庫。MySQL通過SSH隧道訪問被拒絕
我已經設置了命令隧道:
ssh [email protected] -L 3307:remote_mysql_hostname:3306
我可以全成連接使用HeidiSQL此設置:
hostname: localhost
user: remote_mysql_user_login
password: remote_mysql_user_password
port: 3307
但是當我使用PDO在PHP連接時,我得到:
拒絕訪問用戶remote_mysql_user_login'@ 'localhost' 的(使用密碼:YES)
個
我PDO是dns某事像這樣:
mysql:type=Core_Db_Adapter_Pdo_Mysql;host=localhost;port=3307;dbname=db_name;
哪裏招?
解決方案:
@symcbean的感謝!
問題是(如@symcbean所示)在主機名中。
更改爲「127.0.0.1」解決這個問題。**
嘗試使用127.0.0.1。當mysql看到'localhost'時,它會嘗試通過文件系統套接字(更快和更可靠)而不是網絡套接字進行連接 – symcbean