我试图分解在rubymine上进行AWSdebugging成小块的任务 。 我想连接到AWS上运行的MySQL服务器。 所以我做了以下几点:
首先:build立一个ssh隧道,将所有本地主机请求转发到端口3307到AWS上的端口3306:
ssh -l ubuntu -i 'path/to/private/key/privateKey.cer' -L 3307:aws.port:3306 aws.port -N -v -v
第二:连接到端口3307上的MySQL
mysql -h 127.0.0.1 -P 3307 -u root -p
问题:它在我的主机上失败并出现以下错误:
ERROR 1130 (HY000): Host '178.135.138.61' is not allowed to connect to this MySQL server
AWS上的日志输出如下:
debug1: Connection to port 3307 forwarding to 54.193.1.19 port 3306 requested. debug2: fd 7 setting TCP_NODELAY debug1: channel 2: new [direct-tcpip] channel 2: open failed: connect failed: Connection refused debug2: channel 2: zombie debug2: channel 2: garbage collecting debug1: channel 2: free: direct-tcpip: listening port 3307 for 54.193.1.19 port 3306, connect from 127.0.0.1 port 64938, nchannels 3
笔记:
ssh连接 /etc/hosts.deny没有列出localhost或127.0.0.1。 想法?
错误消息
ERROR 1130 (HY000): Host '178.135.138.61' is not allowed to connect to this MySQL server
来自MySQL。 要允许用户root远程访问,那么你需要在mysql服务器上特别允许这个特定的数据库
mysql -u root -p mysql> grant all privileges on somedatabase.* to 'root'@'178.135.138.61' identified by 'somepassword'; mysql> flush privileges;
这将允许用户名root从178.135.138.61连接到mysql,并具有某些数据库的所有权限。
您应该仔细阅读MySQL安全性文档 ,特别是访问控制和用户pipe理章节。