Access denied for user database user on newly added database (after editing server)

Story of the issue:

One of the virtual servers on Virtualmin was used only for email. Today I was ready to move the website to this virtual server so the steps I took are:

Edit Virtual Server >
Enabled: Apache website enabled? Enabled: MySQL database enabled?

A database was created for this server I've created a new user under this server and gave it permissions to the newly added database.

When installing the website and trying to connect it to the database I get the following error: PDOException: SQLSTATE[HY000] [1045] Access denied for user 'database_user'@'localhost' (using password: YES) in lock_may_be_available() ...

Things I have checked: I've triple checked that the username and passwords are correct I've checked that the user indeed has permissions for that database. I also tried to create a new database and a new user and assign the new user to the new database but got the same results. When connecting the website to the database, I have tried and used the "root" to verify the issue is not related to the website and the connections works.

I would appreciate any advice on how to fix this issue.

Closed (works as designed)


Does this domain perhaps have a different username or password set for MySQL? You can see on the Edit Databases page.

For this domain, I have created a new user and gave it permissions for the MySQL. I have also added the password of that user in the "Change database passwords" under the "edit databases" page. I've checked the user and password so many times before posting here, it should work but it's not for some reason. Here is a screenshot showing the user and the MySQL access:

Ilia's picture
Submitted by Ilia on Mon, 03/30/2020 - 09:16

Have you upgrade your MySQL/MariaDB to some other version other than that provided by CentOS 7 repos?

Can you connect to database from console using command:

mysql -u user -p

Try both new and old passwords.

I managed to log in!!! thank you. At first, I tried what you suggested but both users I did not manage to log in. I then went to "Edit Databases" > "Passwords" and entered the domain user's password again. After doing that trying this mysql -u user -p it worked. So I edited by website database connection with the user and password and it worked! Thanks again.