我在 EC2 服务器中有 2 个实例,一个实例具有 mysql 数据库和存储在其中的内容,另一个实例用于访问存储在第一个实例中的数据。
我需要创建一个存储在数据库中的具有只读访问权限的用户。
所以
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
grant select on DBname.* to 'chowzter'@'localhost';
错误
ERROR 1130 (HY000): Host 'ip-xx-xx-xxx-xxx.ec2.internal' is not allowed to connect to this MySQL server
2.CREATE USER 'username'@'ec2-xx-xx-xx-xxx.compute-1.amazonaws.com' IDENTIFIED BY 'password'
grant select on DBname.* to 'username'@'ec2-xx-xx-xxx-xxx.compute-1.amazonaws.com';
这次使用的 ip 地址是second instance
命令获取的内部 IP。
ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 12:31:41:02:58:47 brd ff:ff:ff:ff:ff:ff
inet **XX.XX.XX.XXX/23** brd YY.YYY.YY.YYY scope global eth0
inet6 fe80::1031:41ff:fe02:5847/64 scope link
valid_lft forever preferred_lft forever
ip地址:“XX.XXX.XX.XXX/23”
命令:mysql -hxx.xx.xxx.xxx -uusername -ppassword
错误
ERROR 1045 (28000): Access denied for user 'username'@'ip-xx-xx-xxx-xxx.ec2.internal' (using password: YES)
任何想法如何解决它?