Cannot create PoolableConnectionFactory (Access denied for user ''@'localhost'

前端 未结 2 1766
太阳男子
太阳男子 2021-01-12 01:01

I have been trying to set up a DatabaseConnectionPool for a web app for the last couple of days with no success. I have read the relevant sections of the Tomcat docs and a g

相关标签:
2条回答
  • 2021-01-12 01:01

    Your setup looks fine. This looks to purly be a permissions problem.

    You need to grant that user access in mysql. While Java will connect to localhost, it will do so using tcp/ip - however in mysql localhost and 127.0.0.1 have different meaning. Issuing this SQL should do the trick.

    grant all on twitter.* to 'root'@'127.0.0.1' identified by 'mypwd';
    

    That assumes Java resolves 'localhost' to 127.0.0.1, if things still doesn't work, you could try changing your connection string to "jdbc:mysql://127.0.0.1:3306/twitter"

    Should I have this in my context.xml or just the normal password?

    As you have it now, the plaintext password.

    0 讨论(0)
  • 2021-01-12 01:27

    In your configuration context.xml for the webapp you have to change user="root" by username="root"

    0 讨论(0)
提交回复
热议问题