在最近重新格式化我的硬盘驱动器后,我无法使本地Java / Tomcat / MySQL堆栈正常工作.
这是一个干净的MySQL安装,在Mac OSX 10.7.3(Lion)上运行.
我得到的错误是当我的tomcat实例启动并尝试连接时:
SEVERE: Servlet /concorde-web threw load() exception
java.sql.SQLException: Access denied for user 'concorde'@'localhost' (using password: YES)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
采取的步骤:
>我已经设置了concorde @ localhost的密码,如here和here所述
>我可以使用相同的凭据从控制台进行连接.以下所有工作:
mysql -u concorde -h localhost -p
mysql -u concorde -p
mysql -u concorde -h localhost -D concorde -p
// the app is trying to connect as user concorde to db concorde
>我已确保协调用户拥有权利 – 不仅来自localhost,而且还有任何地方:
GRANT ALL ON concorde.* TO 'concorde'@'%';
FLUSH PRIVELEDGES;
我错过了什么?
除此之外,我可以采取哪些步骤来弄清楚这里发生了什么?有没有我可以检查的日志?
编辑
根据要求,这是我正在使用的代码.
但是,在重新格式化我的硬盘驱动器之前,这段代码工作正常,所以我怀疑问题在于它.
该应用程序在一个弹簧容器中运行,并且在Spring的启动期间,事情已经结束了.
以下是相关的bean声明:
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
value="jdbc:mysql://${database.host}:${database.port}/${database.name}" />
而且,这里是定义的属性:
hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
database.name=concorde
database.username=concorde
database.password=password
database.host=localhost
database.port=3306
此外,这里是权限查询的(删节)输出:
mysql> select * from information_schema.user_privileges;
| 'concorde'@'localhost' | def | USAGE | NO |
| ''@'localhost' | def | USAGE | NO |
| ''@'Marty-Pitts-MacBook-Pro.local' | def | USAGE | NO |
| 'concorde'@'%' | def | USAGE | NO |
+----------------------------------------+---------------+-------------------------+--------------+
注意 – 这是通过使用root登录来运行的.
我怀疑在那里为我的用户显示的NO有一个线索,但我不确定如何解释这些数据.
mysql> select * from information_schema.SCHEMA_PRIVILEGES;
+------------------------+---------------+--------------+-------------------------+--------------+
| GRANTEE | TABLE_CATALOG | TABLE_SCHEMA | PRIVILEGE_TYPE | IS_GRANTABLE |
+------------------------+---------------+--------------+-------------------------+--------------+
| 'concorde'@'localhost' | def | concorde | SELECT | YES |
| 'concorde'@'localhost' | def | concorde | INSERT | YES |
| 'concorde'@'localhost' | def | concorde | UPDATE | YES |
| 'concorde'@'localhost' | def | concorde | DELETE | YES |
| 'concorde'@'localhost' | def | concorde | CREATE | YES |
| 'concorde'@'localhost' | def | concorde | DROP | YES |
| 'concorde'@'localhost' | def | concorde | REFERENCES | YES |
| 'concorde'@'localhost' | def | concorde | INDEX | YES |
| 'concorde'@'localhost' | def | concorde | ALTER | YES |
| 'concorde'@'localhost' | def | concorde | CREATE TEMPORARY TABLES | YES |
| 'concorde'@'localhost' | def | concorde | LOCK TABLES | YES |
| 'concorde'@'localhost' | def | concorde | EXECUTE | YES |
| 'concorde'@'localhost' | def | concorde | CREATE VIEW | YES |
| 'concorde'@'localhost' | def | concorde | SHOW VIEW | YES |
| 'concorde'@'localhost' | def | concorde | CREATE ROUTINE | YES |
| 'concorde'@'localhost' | def | concorde | ALTER ROUTINE | YES |
| 'concorde'@'localhost' | def | concorde | EVENT | YES |
| 'concorde'@'localhost' | def | concorde | TRIGGER | YES |
| 'concorde'@'%' | def | concorde | SELECT | NO |
| 'concorde'@'%' | def | concorde | INSERT | NO |
| 'concorde'@'%' | def | concorde | UPDATE | NO |
| 'concorde'@'%' | def | concorde | DELETE | NO |
| 'concorde'@'%' | def | concorde | CREATE | NO |
| 'concorde'@'%' | def | concorde | DROP | NO |
| 'concorde'@'%' | def | concorde | REFERENCES | NO |
| 'concorde'@'%' | def | concorde | INDEX | NO |
| 'concorde'@'%' | def | concorde | ALTER | NO |
| 'concorde'@'%' | def | concorde | CREATE TEMPORARY TABLES | NO |
| 'concorde'@'%' | def | concorde | LOCK TABLES | NO |
| 'concorde'@'%' | def | concorde | EXECUTE | NO |
| 'concorde'@'%' | def | concorde | CREATE VIEW | NO |
| 'concorde'@'%' | def | concorde | SHOW VIEW | NO |
| 'concorde'@'%' | def | concorde | CREATE ROUTINE | NO |
| 'concorde'@'%' | def | concorde | ALTER ROUTINE | NO |
| 'concorde'@'%' | def | concorde | EVENT | NO |
| 'concorde'@'%' | def | concorde | TRIGGER | NO |
解决方法:
由于您似乎可以使用命令行中的预期凭据登录,因此我怀疑您的属性是否正确地替换为“dataSource”bean.
尝试暂时硬编码dataSource bean的所有参数.
如果可行,则不会设置您的属性.
标签:java,mysql
来源: https://codeday.me/bug/20190626/1291926.html