java.sql.SQLException: Access denied for user

后端 未结 2 429
半阙折子戏
半阙折子戏 2021-01-22 17:38

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

相关标签:
2条回答
  • 2021-01-22 17:49

    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.

    0 讨论(0)
  • 2021-01-22 18:02

    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`@`%`;
    
    0 讨论(0)
提交回复
热议问题