doukangbin9698 2013-04-10 03:49
浏览 51

无法连接到远程MySQL服务器(使用默认服务器)

I'm trying to connect to an AWS MySQL server from my VPS, but no matter what I try, I just get access denied, my user has privileges to connect from any host.

If I try to connect via PHP:

$db = new mysqli('mysite.cufncdsjslka.us-east-1.rds.amazonaws.com', 'my_user', 'my_pass', 'my_db');

Gives me: Warning: mysqli::mysqli(): (28000/1045): Access denied for user 'my_user'@'XXXX.myhost.com' (using password: YES) in /home/me/shopify/libraries/db.lib.php on line 4

If I try to connect via the MySQL CLI:

mysql -h mysite.cufncdsjslka.us-east-1.rds.amazonaws.com -umy_user -p

Gives me: ERROR 1045 (28000): Access denied for user 'my_user'@'xxxx.myhost.com' (using password: YES)

This command works flawlessly on my PC, but not on my VPS.

I'm assuming it's some sort of security setting preventing MySQL from using external servers?

My VPS is running Debian squeeze with the LAMP components all from the standard Debian packages except for PHP which I manually updated to 5.4.

I'm posting this as a new question since most similar questions I've found on SO were a permissions issue (I've given my MySQL user priveliges to connect from any host) or a SELinux issue (which AFAIK doesn't apply to Debian)

  • 写回答

1条回答 默认 最新

  • douwen3973 2013-04-10 17:25
    关注

    OK.

    I have seen this problem number of times for many different reasons. Since I cannot see your server or your logs so I am guessing from the information that there could be bind address issue.

    In my.cnf check

    bind-address=YOUR-SERVER-IP 
    

    change it to the the ipaddress of your mysql server for example 81.92.33.45

    restart mysql after this. And if you are still unable to connect then let me know with the error info from log and I will look again.

    Secondly make sure iptables are not causing problems.

    iptables -A INPUT -i eth0 -p tcp --destination-port 3306 -j ACCEPT
    
    评论

报告相同问题?

悬赏问题

  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序