我在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` 文件。
你能告诉我我错过了什么吗?
2条答案
按热度按时间chy5wohz1#
[已解决]
我解决了这个问题是因为学校的wi-fi。也许有什么…你知道的。
所以连接被拒绝了
'Connection failed: Access denied for user 'yj'@'some-ip'
. 以及'some-ip'
和我用的不一样。所以我用这个ip创建用户。现在,工作顺利。我希望这有帮助。
ubby3x7f2#
你试过:
您可以通过以下方式检查用户权限:
尝试替换
'localhost'
你用的主机,我猜是: