java.sql.SQLException: Access denied for user ‘xxx‘@‘localhost‘ (using password: YES)

错误日志:

java.sql.SQLException: Access denied for user 'xxx'@'localhost' (using password: YES)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129) ~[mysql-connector-java-8.0.25.jar:8.0.25]
	at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) ~[mysql-connector-java-8.0.25.jar:8.0.25]
	at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:833) ~[mysql-connector-java-8.0.25.jar:8.0.25]
	at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:453) ~[mysql-connector-java-8.0.25.jar:8.0.25]
	at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246) ~[mysql-connector-java-8.0.25.jar:8.0.25]
	at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198) ~[mysql-connector-java-8.0.25.jar:8.0.25]
	at com.mysql.cj.jdbc.MysqlDataSource.getConnection(MysqlDataSource.java:416) ~[mysql-connector-java-8.0.25.jar:8.0.25]
	at com.mysql.cj.jdbc.MysqlDataSource.getConnection(MysqlDataSource.java:128) ~[mysql-connector-java-8.0.25.jar:8.0.25]
	at com.mysql.cj.jdbc.MysqlDataSource.getConnection(MysqlDataSource.java:113) ~[mysql-connector-java-8.0.25.jar:8.0.25]
	....
2022-07-10 11:46:33.555  INFO 23360 --- [  restartedMain] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MySQL57Dialect
2022-07-10 11:46:33.967  WARN 23360 --- [  restartedMain] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 1045, SQLState: 28000
2022-07-10 11:46:33.967 ERROR 23360 --- [  restartedMain] o.h.engine.jdbc.spi.SqlExceptionHelper   : Access denied for user 'xxx'@'localhost' (using password: YES)
2022-07-10 11:46:33.972 ERROR 23360 --- [  restartedMain] j.LocalContainerEntityManagerFactoryBean : Failed to initialize JPA EntityManagerFactory: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.exception.GenericJDBCException: Unable to open JDBC Connection for DDL execution
2022-07-10 11:46:33.973  WARN 23360 --- [  restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.exception.GenericJDBCException: Unable to open JDBC Connection for DDL execution
2022-07-10 11:46:33.975  INFO 23360 --- [  restartedMain] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2022-07-10 11:46:33.984  INFO 23360 --- [  restartedMain] ConditionEvaluationReportLoggingListener : 

可能的问题

1. 配置了数据库连接池:

问题: 配置了数据库连接池:spriing.datasource.type: com.mysql.cj.jdbc.MysqlConnectionPoolDataSource
解决办法 改用阿里巴巴的连接池

	1. pom文件添加依赖 
	 <dependency>
        <groupId>com.alibaba</groupId>
        <artifactId>druid</artifactId>
        <version>1.2.6</version>
    </dependency>
	2. 修改 yml 文件 
	spriing.datasource.type:  com.alibaba.druid.pool.DruidDataSource
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值