Hi I'm working on a Liferay portlet that accesses the database using JPA. I'm using Tomcat 7 and MySQL.
嗨,我正在使用一个使用JPA访问数据库的Liferay portlet。我正在使用Tomcat 7和MySQL。
This portlet works fine in my machine but when I move the portlet to a test environment in another server and try to use it in the test portal I get the following error:
这个portlet在我的机器上工作正常但是当我将portlet移动到另一个服务器中的测试环境并尝试在测试门户中使用它时,我收到以下错误:
Access denied for user 'root'@'localhost' (using password: YES)
用户'root'@'localhost'拒绝访问(使用密码:YES)
The database connection database in my persistence.xml is ok.
我的persistence.xml中的数据库连接数据库没问题。
I tried putting wrong connection data in the persistence.xml to see if the error changed but it didn't. For example I set the user as "wronguser" and when I deployed the portlet and tried to use it again I got exactly the same error:
我尝试在persistence.xml中输入错误的连接数据,以查看错误是否已更改但未更改。例如,我将用户设置为“wronguser”,当我部署portlet并尝试再次使用它时,我得到完全相同的错误:
Access denied for user 'root'@'localhost' (using password: YES)
用户'root'@'localhost'拒绝访问(使用密码:YES)
Even if I change the database name or URL the error is always the same. It's like something is not getting updated. I tried deleting the Tomcat temp folder but didn't help.
即使我更改数据库名称或URL,错误也始终相同。这就像有些东西没有得到更新。我尝试删除Tomcat临时文件夹,但没有帮助。
Any ideas?
Thanks in advance.
提前致谢。
1 个解决方案
#1
0
I tried putting wrong connection data in the persistence.xml to see if the error changed but it didn't. For example I set the user as "wronguser" and when I deployed the portlet and tried to use it again I got exactly the same error:
我尝试在persistence.xml中输入错误的连接数据,以查看错误是否已更改但未更改。例如,我将用户设置为“wronguser”,当我部署portlet并尝试再次使用它时,我得到完全相同的错误:
This just shows that the username/password given to mysql at the end is not coming from your configuration file as expected, but from to-be-identified-elsewhere.
这只是表明最后给mysql的用户名/密码不是按照预期来自你的配置文件,而是来自其他地方的待识别。
Until you see mysql complaining about "wronguser" not being able to connect, this is the first roadblock to clear, and the problem is most likely in the application setup, not in mysql.
直到你看到mysql抱怨“wronguser”无法连接,这是第一个清除的障碍,问题很可能出现在应用程序设置中,而不是在mysql中。
Should the mysql server complain later about privileges for "wronguser", then sure, the area to investigate then will be grants for this user, but you need to convey the proper user/host/password information to the server first.
如果mysql服务器稍后会抱怨“wronguser”的权限,那么当然,要调查的区域将是该用户的授权,但是您需要首先向服务器传达正确的用户/主机/密码信息。
#1
0
I tried putting wrong connection data in the persistence.xml to see if the error changed but it didn't. For example I set the user as "wronguser" and when I deployed the portlet and tried to use it again I got exactly the same error:
我尝试在persistence.xml中输入错误的连接数据,以查看错误是否已更改但未更改。例如,我将用户设置为“wronguser”,当我部署portlet并尝试再次使用它时,我得到完全相同的错误:
This just shows that the username/password given to mysql at the end is not coming from your configuration file as expected, but from to-be-identified-elsewhere.
这只是表明最后给mysql的用户名/密码不是按照预期来自你的配置文件,而是来自其他地方的待识别。
Until you see mysql complaining about "wronguser" not being able to connect, this is the first roadblock to clear, and the problem is most likely in the application setup, not in mysql.
直到你看到mysql抱怨“wronguser”无法连接,这是第一个清除的障碍,问题很可能出现在应用程序设置中,而不是在mysql中。
Should the mysql server complain later about privileges for "wronguser", then sure, the area to investigate then will be grants for this user, but you need to convey the proper user/host/password information to the server first.
如果mysql服务器稍后会抱怨“wronguser”的权限,那么当然,要调查的区域将是该用户的授权,但是您需要首先向服务器传达正确的用户/主机/密码信息。