After changing password of MySQL or MariaDB administration user, such as root, Virtualmin no longer has access to the database of the virtual servers. When attempting to manage database of a virtual server via “Edit Databases,” Virtualmin will prompt that “You do not have access to this MySQL database.”

Virtualmin No Access to Database

Cause

The reason of the error is because Virtualmin/Webmin saves the password of the MySQL/MariaDB administration user, i.e. root. When the administration password is changed outside of Virtualmin/Webmin, Virtualmin/Webmin does not know about it, does not update to the new password, and hence is still trying to use the old password to connect to MySQL/MariaDB database server.

Normally, the error only happens if you change the password for root or the administration user defined in Virtualmin/Webmin via phpMyAdmin or other mysql clients, which bypass Webmin/Virtualmin.

Solution

Login to Virtualmin or Webmin, then go to Webmin -> Servers -> MySQL Database Server. You will be prompted with the following message:

Webmin needs to know your MySQL administration login and password in order to manage your database. Please enter your administration username (usually root) and password below.

The full MySQL error message was : DBI connect failed : Access denied for user ‘root’@’localhost’ (using password: YES)

Update MySQL Administration User Credentials

Enter the correct user name and password credentials for a MySQL/MariaDB administrator user. For example, root with its new password. You can also specify other user account with has administrative access to the database server, if you decide to change the user account used by Webmin/Virtualmin.

Once you enter the correct login, Virtualmin/Webmin will automatically save the updated credentials for future use.

Note: You can, of course, also change the password of administration user back to its original password too. To avoid re-occurrence, always change the administration password from the MySQL Database Server module of Webmin.