我正在尝试从Spring启动连接MySQL db,但我收到此错误为:
java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129) ~[mysql-connector-java-8.0.19.jar:8.0.19]
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) ~[mysql-connector-java-8.0.19.jar:8.0.19]
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) ~[mysql-connector-java-8.0.19.jar:8.0.19]
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:836) ~[mysql-connector-java-8.0.19.jar:8.0.19]
at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:456) ~[mysql-connector-java-8.0.19.jar:8.0.19]
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246) ~[mysql-connector-java-8.0.19.jar:8.0.19]
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:197) ~[mysql-connector-java-8.0.19.jar:8.0.19]
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138) ~[HikariCP-3.4.2.jar:na]
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:354) ~[HikariCP-3.4.2.jar:na]
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:202) ~[HikariCP-3.4.2.jar:na]
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:473) [HikariCP-3.4.2.jar:na]
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:554) [HikariCP-3.4.2.jar:na]
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115) [HikariCP-3.4.2.jar:na]
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112) [HikariCP-3.4.2.jar:na]
at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) [hibernate-core-5.4.12.Final.jar:5.4.12.Final]
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:180) [hibernate-core-5.4.12.Final.jar:5.4.12.Final]
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:68) [hibernate-core-5.4.12.Final.jar:5.4.12.Final]
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35) [hibernate-core-5.4.12.Final.jar:5.4.12.Final]
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:101) [hibernate-core-5.4.12.Final.jar:5.4.12.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263) [hibernate-core-5.4.12.Final.jar:5.4.12.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:237) [hibernate-core-5.4.12.Final.jar:5.4.12.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214) [hibernate-core-5.4.12.Final.jar:5.4.12.Final]
at org.hibernate.id.factory.internal.DefaultIdentifierGeneratorFactory.injectServices(DefaultIdentifierGeneratorFactory.java:152) [hibernate-core-5.4.12.Final.jar:5.4.12.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.injectDependencies(AbstractServiceRegistryImpl.java:286) [hibernate-core-5.4.12.Final.jar:5.4.12.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:243) [hibernate-core-5.4.12.Final.jar:5.4.12.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214) [hibernate-core-5.4.12.Final.jar:5.4.12.Final]
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.<init>(InFlightMetadataCollectorImpl.java:176) [hibernate-core-5.4.12.Final.jar:5.4.12.Final]
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:118) [hibernate-core-5.4.12.Final.jar:5.4.12.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1202) [hibernate-core-5.4.12.Final.jar:5.4.12.Final]
我的application.properties档案看起来像
spring.datasource.url= jdbc:mysql://localhost:3306/db_carrepairmaster
spring.datasource.username=root
spring.datasource.password=root
spring.jpa.database=mysql
spring.datasource.platform=mysql
# Show or not log for each sql query
spring.jpa.show-sql = true
# Hibernate ddl auto (create, create-drop, update): with "update" the database
# schema will be automatically updated accordingly to java entities found in
# the project
spring.jpa.hibernate.ddl-auto = update
用户名“root”和密码“root”正确,因为我可以从命令行登录到root。我已经尝试了java.sql中的所有方法。SQLException:用户“root”@“ocalhost”的访问被拒绝(使用密码:YES)
我遇到了非常相似的问题,我在设置配置属性时提出了创建 YAML (application.yml),而不是 application.properties。我在 src/main/resources/application.yml 中编写了以下代码,如下所示:
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/db_carrepairmaster
username: root
password: root
终于发现了我在编写application.properties文件时犯的愚蠢错误。我误在密码后面加了一个空格,在我的例子中是“root”。因此,在application.properties文件中写入密码时请小心。Spring Boot认为这个空格是密码字符。
问题内容: 我正在尝试从数据库中获取记录。但我正面临拒绝访问的问题。我尝试了在堆栈溢出中提到的其他解决方案,例如向用户授予特权。 访问数据库的代码: 错误的堆栈跟踪: 在这种情况下可能是什么问题。我尝试创建一个新的数据库,但是也没有用。 问题答案: 问题是授予表根用户的权限。’root’@’%’没有任何权限。.就像我以前用作连接地址一样,因此它给出了拒绝访问错误.. 是IP地址的通配符。所以mys
这是我的代码: 对于dbServername,我尝试过使用localhost、localhost:8080、localhost:3306和127.0.0.1,但只有127.0.0.1和localhost:3306似乎通过了测试,并给出了可能的错误。我在localhost(没有这样的文件或目录*)和localhost:8080(MySQL已经消失)中遇到了不同的错误。 因此,考虑到IP as dbS
在Ubuntu中使用MySQL我做了以下步骤: 我收到一个错误: 拒绝用户“root”@"localhost“的访问(使用密码:YES)
问题内容: 当我在PHPMyAdmin中设置root密码时,出现以下错误: 我无法打开PHPMyAdmin面板。我究竟做错了什么? 问题答案: 编辑您的phpmyadmin config.inc.php文件,如果您有密码,请在以下代码中将其插入密码前面:
问题内容: $ ./mysqladmin -u root -p ‘ 编辑 ‘ 输入密码: mysqladmin:在“ localhost”处连接到服务器失败错误: “对用户“ root” @“ localhost”的访问被拒绝(使用密码:是) 我怎样才能解决这个问题? 问题答案: 打开并编辑或,具体取决于您的发行版。 添加下 重启MySQL 您现在应该可以使用以下命令登录mysql 跑 设置新密码