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

时间:2024-11-15 10:11:16

报错:
Caused by: : 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: ------
: 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’;