mysql - 当我在 amazon-ec2 中访问 mysqldb 时,远程访问被拒绝。(1045,“用户'user-name'@'some-ip'的访问被拒绝)
问题描述
我在 AWS 中创建了一个 ec2 用户服务器。然后安装mysql我已经用谷歌搜索了这个问题然后我检查我做得很好。
# mysql --version
mysql Ver 14.14 Distrib 5.5.58, for Linux (x86_64) using readline 5.1
首先,设置 aws 入站 0.0.0.0:3306
# netstat -tln
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
其次,为 0.0.0.0 创建 mysql 用户 'yj'。(我也试过'%'。但它不起作用。所以我也试过'0.0.0.0'。)
mysql> select host, user, password from mysql.user;
+------------------+------+-------------------------------------------+
| host | user | password |
+------------------+------+-------------------------------------------+
| localhost | root | *some-password |
| ip-172-31-86-160 | root | |
| 127.0.0.1 | root | |
| ::1 | root | |
| localhost | | |
| ip-172-31-86-160 | | |
| 0.0.0.0 | yj | *some-password |
+------------------+------+-------------------------------------------+
第三,检查/etc/my.cnf
文件。
# cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mysqld according to the
# instructions in http://fedoraproject.org/wiki/Systemd
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
人们说修改bind-address=127.0.0.1
为bind-address=0.0.0.0
. 但是我的 .cnf 文件没有任何绑定地址。所以我试图在/etc/mysql/mysql.conf.d
或/etc/mysql.conf
等等中找到另一个conf文件。但是没有/etc/my.cnf
文件就没有什么。
你能告诉我有什么我想念的吗?
解决方案
[解决了]
我解决了因为学校无线网络的问题。也许有什么……你知道的。
所以连接被拒绝的消息'Connection failed: Access denied for user 'yj'@'some-ip'
。和'some-ip'
我使用的不同。所以我使用该 ip 创建用户。现在,运作良好。
我希望这个对你有用。
推荐阅读
- python - 为什么 gevent 不提供自己的功能库,而不是猴子修补现有的功能?
- highcharts - Highcharts:如何创建一个可以导出为图像的字符串表?
- java - 如何在方法和线程之间共享字符串?
- angular - 将标记针保持在中心我会拖动地图吗
- bash - Jenkinsfile 没有执行整个 shell 脚本
- c++ - 是否可以使用符合 C++17 的 C++14 创建迭代器?
- ios - 您通常如何在 iOS 键盘上显示此“密码”按钮?
- sql - sql developer更改连接密码
- javascript - db.all 函数不作为数组变量返回
- html - SVG 在加载时超大,直到 CSS 启动