问题:java.sql.SQLException: null, message from server: "Host 'ip-172-31-28-108.cn-northwest-1.compute.internal' is not allowed to connect to this MySQL server"
原因:mysql数据库不允许这个IP远程链接
解决:
#链接数据库
mysql -u root -p
#查询允许链接的ip
use mysql;
select host from user where user='root';
mysql> select host from user where user='root';
+---------------+
| host |
+---------------+
| 127.0.0.1 |
| localhost |
+---------------+
#设置远程连接的IP地址,然后刷新配置
GRANT ALL PRIVILEGES ON *.* TO 'root'@'IP地址' IDENTIFIED BY '数据库密码' WITH GRANT OPTION;
flush privileges; //立即生效