maven打包之前是在test环境,想发布到product环境,发现最后打包测试时发现了问题
org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is java.sql.SQLException: null, message from server: "Host '211.142.247.144' is not allowed to connect to this MySQL server"
Caused by: java.sql.SQLException: null, message from server: "Host '211.142.247.144' is not allowed to connect to this MySQL server"
意思就是本地无法连接远程的mysql数据库:需要在远程的数据库给权限
解决方法:只需要在远程的数据库将root用户主机换成所有的用户地址都可以连接,用 % 替代
先登录远程的数据库 mysql -u root -p
use mysql;
select user,host from user;
update user set host='%' where user='root';
flush privileges;
出现了1062这个错误直接不予理会,因为有多个root的用户,直接 flush privileges;刷新权限再次连接