Unable to open a test connection to the given database.

 今天在做项目的时候遇到了这样的问题:

org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Unable to open a test connection to the given database. JDBC url = jdbc:mysql://*.*.*.*:3306/*?useUnicode=true&characterEncoding=utf8, username = root. Terminating connection pool. Original Exception: ------
java.sql.SQLException: Access denied for user 'root'@'supertool-28.local' (using password: NO)

解决方案:

java.sql.SQLException: Access denied for user 'root'@'supertool-28.local' (using password: NO)

提示很明确是从我这台机器以root身份登录数据库,被拒绝,

解决方法:在数据库上添加我这台机器的授权:  grant all on *.* root@%;从所有机器上以root身份登录,都可以得到所有表的所有权限。


给用户授权: grant all on *.* root@%;

授权完的更新数据库的user表:flush privileges;

删除用户: delete from user where user='sss' and host='localhost' ;

参考:http://www.isstudy.com/mysql/479.html


下面是我搜了一个和我遇到的问题一模一样,但是好像处理方法不一样,大家可以参考参考:

http://yangchunhe.iteye.com/blog/1664254

你可能感兴趣的:(Unable to open a test connection to the given database.)