java.sql.SQLException: Access denied for user

蓝咒 提交于 2019-12-20 03:45:08

问题


I want to create an user that can access from any hosts to Mysql server

I use

create user abc@10.10.131.17 identified by 'abc123'

and

grant all privileges mydb.* to 'abc'@'%';

But when i run client,the error occurs: "java.sql.SQLException: Access denied for user 'abc'@'10.10.0.7' (using password: YES)

help me,please!


回答1:


One obvious guess would be that you didn't do FLUSH PRIVILEGES; after issuing GRANT statement.

Another obvious guess (not sure if typo in the question) is that syntax of GRANT is GRANT ALL PRIVILEGES ON mydb.* TO 'abc'@'%';, with ON in it.




回答2:


You have created an user with allowing IP 10.10.131.17 and you are trying to connect MySQL Server from IP 10.10.10.7. So it won't work. To access MySQL Server you have to create user allowing IP 10.10.10.7 or allowing all IPs using %.

CREATE USER `abc`@`10.10.10.7` IDENTIFIED BY 'abc123' 
GRANT ALL PRIVILEGES mydb.* TO `abc`@`10.10.10.7`;

OR

CREATE USER `abc`@`%` IDENTIFIED BY 'abc123' 
GRANT ALL PRIVILEGES mydb.* TO `abc`@`%`;


来源:https://stackoverflow.com/questions/14058486/java-sql-sqlexception-access-denied-for-user

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!