com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:拒绝用户"@'localhost"访问数据库 [英] com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Access denied for user ''@'localhost' to database

查看:108
本文介绍了com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:拒绝用户"@'localhost"访问数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想连接到数据库并使用Java创建表. Butm它引发以下异常:

I want to connect to my database and create the tables using Java. Butm It throws below exception:

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:访问 拒绝用户"@'localhost"进入数据库

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Access denied for user ''@'localhost' to database

推荐答案

检查是否允许用户进行远程连接,在数据库上的sql query下面运行以允许您的用户从任何地方进行连接.

Check if user is allowed for remote connection, run below sql query on your database to allow your user to connect from everywhere.

允许用户从任何地方连接

`GRANT ALL ON *.* to <user-name>@'<ip>' IDENTIFIED BY '<password>'`

root用户的示例:-

GRANT ALL ON *.* to root@'%' IDENTIFIED BY 'root'; 
// grant root user to connect from everywhere(%) , which has root password.

这篇关于com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:拒绝用户"@'localhost"访问数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆