Due to the change of temporary requirements, the development schedule was very tight, and a service needed to be developed independently quickly, so I used Springboot to provide the service. After the development was completed, I coordinated with the front-end, and everything was normal in local debugging. The deployment to the console of the server’s front-end request interface reported as follows:

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

This error message clearly means:

User XXXX is denied access to the database

I checked my config file for the first time: spring.datasource. Name = root

Confirm root and retrieve my code without XXXX field….

I configured the root user, that XXXX user is from where? It’s not scientific. Why?

Later, I found that XXXX was the system user name of the server. I suddenly had an Epiphany. I should have mistaken the system user as the database user.

Spring. The datasource. Name = root.

Spring. The datasource. Name:

Datasource name to use if “generate-unique-name” is false,when using an embedded database,otherwise Null. (If “generate-unique-name” is false, the data source name is used. Default “testDB”, otherwise null when using embedded database)

Thus, the data source name attribute is used to configure the data source or embedded database. Because of this name, I mistook the system user as the database name, which can be inferred: if there is no configuration of embedded database, name will be taken to the local user name.

spring.datasource.username:

Database login username that is ok.

No-secret login for local database:

The problem is solved, but I have another problem, then why my local configuration is ok, according to the current inference, should also report this error in the local?

The local database has a skip-grant-tables logon that skips privileges

In this way, the database can be accessed successfully even if the user password is not configured.

Mysql 5.7.22 mysql 5.7.22 mysql 5.7.22 mysql 5.7.22

Ini file skip-grant-tables to log in to mysql.

2.user mysql; 

3.update mysql.user set authentication_string=password(‘xxxxx’) where user=’root’ and Host =’localhost’;

4. Restart the mysql service

5. Failed to test the secret-free login

6. User name and password: mysql -uroot -p

                   password : xxxx