Spring Boot MySql Access被用户'root'@'localhost'拒绝 [英] Spring Boot MySql Access denied for user 'root'@'localhost'
问题描述
我有spring boot应用程序,并已部署到远程服务器.该应用程序在我的计算机上运行. MySQL连接URL,用户名和密码是相同的本地和远程MySQL.数据库和应用程序在同一台机器上!
I have spring boot app and deployed to a remote server. The app runs on my computer. MySQL connection URL, user name and password are the same local and remote MySQL. DB and app in same machine!!
我检查了我的连接信息,并执行了以下命令.
I checked my connection info and executed about below commands.
GRANT ALL PRIVILEGES ON burrda.* TO 'root'@'localhost' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
我的application.properties
在下面.
spring.jpa.database-platform=org.hibernate.dialect.MySQL5Dialect
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL57Dialect
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/burrda
spring.datasource.username=root
spring.datasource.password= password
当应用运行时,我得到java.sql.SQLException: Access denied for user 'root'@'localhost'
When apps runs I'm getting java.sql.SQLException: Access denied for user 'root'@'localhost'
我没有这些异常java.sql.SQLException: Access denied for user 'root'@'localhost'
(使用密码:是)或java.sql.SQLException: Access denied for user 'root'@'localhost'
(使用密码:否)
I'm not getting these exceptions java.sql.SQLException: Access denied for user 'root'@'localhost'
(using password: YES) or java.sql.SQLException: Access denied for user 'root'@'localhost'
(using password: NO)
推荐答案
用于授予用户权限的SQL命令不得包含PASSWORD
关键字,它必须类似于:
The SQL command for granting the user must not contain PASSWORD
keyword, it must be like:
GRANT ALL PRIVILEGES ON burrda.* TO 'root'@'localhost' IDENTIFIED BY 'password';
这篇关于Spring Boot MySql Access被用户'root'@'localhost'拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!