Java 用户'root'@'localhost'的mysql访问被拒绝(使用密码:NO)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18693149/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 10:14:36  来源:igfitidea点击:

mysql Access denied for user 'root'@'localhost' (using password: NO)

javamysqlnetbeanspasswordsroot

提问by user1182637

I'm using Netbean 7.3, Glassfish 3.1.2

我使用的是 Netbean 7.3、Glassfish 3.1.2

I always get this error and I cannot proceed to do my project:

我总是收到这个错误,我无法继续做我的项目:

WARNING: RAR5038:Unexpected exception while creating resource for pool mysql_tests_rootPool. Exception : javax.resource.spi.ResourceAllocationException: Connection could not be allocated because: Access denied for user 'root'@'localhost' (using password: NO)

警告:RAR5038:为池 mysql_tests_rootPool 创建资源时出现意外异常。异常:javax.resource.spi.ResourceAllocationException:无法分配连接,因为:用户“root”@“localhost”的访问被拒绝(使用密码:否)

WARNING: RAR5117 : Failed to obtain/create connection from connection pool [ mysql_tests_rootPool ]. Reason : com.sun.appserv.connectors.internal.api.PoolingException: Connection could not be allocated because: Access denied for user 'root'@'localhost' (using password: NO)

警告:RAR5117:无法从连接池 [mysql_tests_rootPool] 获取/创建连接。原因:com.sun.appserv.connectors.internal.api.PoolingException:无法分配连接,因为:用户“root”@“localhost”拒绝访问(使用密码:否)

WARNING: RAR5114 : Error allocating connection : [Error in allocating a connection. Cause: Connection could not be allocated because: Access denied for user 'root'@'localhost' (using password: NO)]

警告:RAR5114:分配连接时出错:[分配连接时出错。原因:无法分配连接,因为:用户“root”@“localhost”的访问被拒绝(使用密码:否)]

Error in getList() -->Error in allocating a connection. Cause: Connection could not be allocated because: Access denied for user 'root'@'localhost' (using password: NO)

getList() 出错 --> 分配连接出错。原因:无法分配连接,因为:用户“root”@“localhost”的访问被拒绝(使用密码:否)

Initially my project cannot even run. But after including these 2 line of code under persistence.xml, my project can run, but it can only access the database once.

最初我的项目甚至无法运行。但是在persistence.xml下包含这两行代码后,我的项目可以运行,但它只能访问数据库一次。

<property name="eclipselink.jdbc.user" value="root"/>
<property name="eclipselink.jdbc.password" value="password"/>

I included "root" and "password" when doing all the setup etc but still, I'm getting this error. Tried a lot of methods but none works!

在进行所有设置等时,我包含了“root”和“password”,但仍然出现此错误。试了很多方法都没有效果!

Please help! Thanks!!

请帮忙!谢谢!!

采纳答案by user1182637

I've solved this error. I'm posting this because someone could have encounter the same thing as me.

我已经解决了这个错误。我发布这个是因为有人可能遇到和我一样的事情。

The problem lies with the data source. Apparently something happen during the creation of data source. The password parameter is missing. So I deleted the current data source and created a new one again and the problem is solved.

问题出在数据源上。显然在创建数据源期间发生了一些事情。缺少密码参数。所以我删除了当前的数据源并重新创建了一个新的数据源,问题解决了。