SpringBoot database connection pool Druid error

 [main] [] [com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure] [dataSource] [55] [] INFO  : Init DruidDataSource
2023-06-16 08:31:28 [main] [] [com.alibaba.druid.pool.DruidDataSource] [init] [929] [] ERROR : init datasource error, url: jdbc:mysql://127.0.0.1:3306/tdp?characterEncoding=utf8
java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)

analyze:

According to the error message, it can be seen that when the system initializes the Druid data source, it finds that the user name used to connect to the MySQL database is 'root', and the password verification fails, so it cannot connect to the database. Common causes are:

1. Username or password is incorrect. You need to use the correct username and password when connecting to the database, otherwise this error will occur.

2. The MySQL server has set connection permission control. If the permission control is enabled on the MySQL server, authorization must be performed in the configuration file or the MySQL command line, otherwise a connection failure will be prompted. Authorization can be performed by executing the following command:

grant all privileges on *.* to 'root'@'localhost' identified by 'your_password' with grant option;

3. The MySQL server is not started. If the MySQL server is not started or freezes, it will result in failure to connect to the database. Problems can be resolved by viewing the MySQL server logs or restarting the service.

4. The listening address of the MySQL server is incorrect. If the listening address of the MySQL server is configured incorrectly, or if it is inconsistent with the address connected to the application, it will fail to connect to the MySQL server. You can solve the problem by modifying the my.cnf configuration file of the MySQL server, or modifying the connection address of the application.

It is necessary to check the above problems one by one according to the specific situation, and make corresponding adjustments and repairs to solve this error.

Guess you like

Origin blog.csdn.net/qq_56489154/article/details/131241238