
我有一个运行 Ubuntu 14.04 的 Amazon AWS EC2 实例。我在其中安装了 MYSQL 5.5。
我正在尝试从运行 Navicat 的本地 Windows10 机器连接到此实例上运行的 MYSQL。
环境状态:
3306 正在收听
netstat -an | grep 3306 -> tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN
MYSQL 已启动
ubuntu@ip-***-**-**-**:/$ sudo service mysql status
mysql start/running, process 28015
从 mysql.user 中选择用户、主机;
| blog | % |
| blog | localhost |
mysql> show grants for 'blog'@'%';
+--------------------------------------------------+
| Grants for blog@% |
+--------------------------------------------------+
| GRANT USAGE ON *.* TO 'blog'@'%' |
| GRANT ALL PRIVILEGES ON `blogdb`.* TO 'blog'@'%' |
+--------------------------------------------------+
2 rows in set (0.00 sec)
telnet from my PC to the server does not work -> need to sleep. will come back tomorrow :)
我使用私钥通过 SSH 连接到 Ubuntu 实例。
前一个问题:
当尝试使用 Windows 进行连接时Navicat在我的 AWS 实例上运行 MYSQL 时出现以下错误:
无法连接到“41.42.434.169”上的 Mysql 服务器(10061“未知错误”)-> 此处所述的 IP 不是我的
我使用的主机名/IP 地址是我的 AWS 实例的公共 IP。
# bind-address = 127.0.0.1
通过在 my.cnf 中注释来解决这个问题
现在我的电脑可以进行 telnet 操作了
编辑
现在我收到以下错误:
拒绝用户访问[电子邮件保护](使用密码:是)
答案1
对于远程访问:
检查 etc\mysql\my.cnf 以确保 bind-address 未设置为 127.0.0.1。请将其设置为 0.0.0.0,或者为了更安全,请添加您的 IP 地址:
bind-address = 127.0.0.1
bind-address = your_public_ip
在mysql表中创建用户:
CREATE USER 'non-root-user'@'localhost' IDENTIFIED BY 'any_password_u_like';
CREATE USER 'non-root-user'@'%' IDENTIFIED BY 'any_password_u_like';
GRANT ALL ON *.* TO 'non-root-user'@'localhost';
GRANT ALL ON *.* TO 'non-root-user'@'%';
AWS 特定
确保您有端口 3306 的入站规则