M S Q L 拒绝连接的解决办法!

报错:
Caused by: java.sql.SQLException: Unable to open a test connection to the given database. JDBC url = jdbc:mysql://VM1:3306/hive?characterEncoding=UTF-8, username = root. Terminating connection pool (set lazyInit to true if you expect to start your database after your app). Original Exception: ------
java.sql.SQLException: Access denied for user ‘root’@‘VM1’ (using password: YES)

解决方案:
1、授权

设置用户root可以在任意IP下被访问:

grant all privileges on . to root@"%" identified by “新密码”;

设置用户root可以在本地被访问:

grant all privileges on . to root@“localhost” identified by “新密码”

刷新权限使之生效

flush privileges;

2、删除对应主机用户

use mysql;

select host,user from user;

drop user ‘username’@‘host’;

你可能感兴趣的:(Mysql)