[英]Not able to insert data in MySQL 8 DB using Spring Boot and JPA
[英]How to fix this error in Spring Boot using Spring Data JPA and MySQL
我尝试使用Spring Data JPA(在Spring Boot应用程序中)连接到MySQL数据库,并且始终出现相同的错误:
java.sql.SQLException: Access denied for user ''@'localhost' (using password: NO)
我的application.properties
看起来像:
spring.datasource.url=jdbc:mysql://localhost:3306/demographics
spring.datasource.data-username=root
spring.datasource.data-password=root
spring.jpa.hibernate.ddl-auto=update
我知道url
, username
和password
都不错。
问题是由于身份验证而与数据库本身创建了连接。 使用命令行或某些工具(例如mysql workbench)执行此操作。
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY '%root%' WITH GRANT OPTION;
看来您在数据库中的帐户不需要密码,所以只需在您的媒体资源中输入空密码
spring.datasource.data-password=
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.