当我在amazon-ec2中访问mysqldb时,远程访问被拒绝(1045,“拒绝访问用户'user name'@'some-ip')

bfrts1fy  于 2021-06-20  发布在  Mysql
关注(0)|答案(2)|浏览(257)

我在aws中创建了一个ec2用户服务器。然后安装mysql我已经谷歌这个问题,然后我检查我做得很好。


# mysql --version

mysql  Ver 14.14 Distrib 5.5.58, for Linux (x86_64) using readline 5.1

首先,设置aws inbound 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文件没有任何绑定地址。所以我想在里面找到另一个conf文件 `/etc/mysql/mysql.conf.d` 或者 `/etc/mysql.conf` 等等。但是没有任何东西 `/etc/my.cnf` 文件。
你能告诉我我错过了什么吗?
chy5wohz

chy5wohz1#

[已解决]
我解决了这个问题是因为学校的wi-fi。也许有什么…你知道的。
所以连接被拒绝了 'Connection failed: Access denied for user 'yj'@'some-ip' . 以及 'some-ip' 和我用的不一样。所以我用这个ip创建用户。现在,工作顺利。
我希望这有帮助。

ubby3x7f

ubby3x7f2#

你试过:

CREATE USER 'yj'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON * . * TO 'yj'@'localhost';
FLUSH PRIVILEGES;

您可以通过以下方式检查用户权限:

SHOW GRANTS yj;

尝试替换 'localhost' 你用的主机,我猜是:

'0.0.0.0'

相关问题