After updating the system with all available updates (it had been about two weeks since the last update), Virtualmin/Webmin are no longer able to connect to the MariaDB database. The same password (the one used by the root user only to connect to MariaDB, and different from the SSH root login password) is still valid for accessing the MySQL root user from the SSH terminal.
To summarize:
Password pasted after running the command:
mysql -u root -p
Access granted.
The same password pasted into the text box shown in the screenshot: Credential error.
Before the update, there were no issues.
I have not tried checking the “Force override the given password, if lost or forgotten” option because I’m afraid it might corrupt the hash and prevent access from the terminal as well.
Since this is a production server, I am avoiding random experimentation. I believe I will clone the environment and test possible solutions on the clone to ensure they do not cause any damage.
After creating a snapshot and setting up a clone, I felt confident enough to run some tests, identify the issue, and fix it.
The problem occurs (apparently only in newer versions, though I’m not sure which component is responsible) when the MySQL root password contains certain special characters such as $ or %. I’m not sure whether it’s just one of them or both. Removing these two special characters from the password resolved the issue. Below is the full procedure:
From the terminal:
mysql -u root -p
Paste the password that has always worked, and you will gain access to MySQL as the root user.
Now let’s update the password (replace NewPassword with your new password):
ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewPassword';
Still inside MySQL:
FLUSH PRIVILEGES;
At this point, the new MySQL root password has been updated.
Now we need to inform Webmin (replace vim with your preferred text editor, e.g., nano):
vim /etc/webmin/mysql/config
Locate pass= and replace the old password with the new one.
From the terminal, restart Webmin (note that on your system the restart command might be different, such as initctl restart webmin):
systemctl restart webmin
After following this procedure, everything started working correctly again.
Can you explain in more detail how or when this bug appeared?
Everything you described doesn’t seem to match the current code. In the latest Webmin versions (which you have installed), special characters in passwords are fully supported.
That said, to resolve your issue, you could simply update the /etc/webmin/mysql/config file manually with the correct pass= value (that contains % or $ or whatever, or re-enter the correct password through the UI.
I periodically update all the server packages. The last time I did it was 21 days ago (I had written two weeks, but I double-checked), and everything was working properly. Today I had about 34 new packages to install, so I performed the update. Afterward, when accessing the MariaDB section, I encountered that error. Simply restarting the service did not produce any positive result.
However, from the terminal I was still able to access the database without any issues. The problem only occurred within Webmin. In the configuration file (/etc/webmin/mysql/config), the password was correct.
At that point, I tried removing those two special characters from the password, updating it both in MySQL and in the configuration file, and it worked.
If you’re telling me that in your code there’s nothing preventing those characters from being used in the password, then it means that the simple update query and the flush privileges command resolved the issue. Since I had removed those two characters, I assumed that was the cause.
Another odd behavior I’ve noticed only since I started using the most recent versions of Webmin/Virtualmin is that when I create a new database user through your tool, even though the user appears and I grant the correct permissions to the proper database, from the application side (my proprietary software) the user is not recognized. To fix it, I have to set the password again via the terminal.
It might even be the same underlying issue, but this is the first time in many years of using Virtualmin that I’ve had a problem with the MySQL root user. The issue with database users needing to be reassigned via the terminal is also recent. Until a few days ago, everything was working correctly.
Unfortunately, I encountered the same issue on another server (same operating system and fully updated to the latest versions). On that server as well, I use the $ character in the password, but unlike what happened with the previous server, the procedure that resolved the issue on the first server did not fix it on the second one. At this point, I have no idea how to resolve it.
This looks fine to me, and special characters in the password work without any issues on my system. Sorry, but I’m not sure why it didn’t work for you.
If I’m not mistaken, the symptom of both issues is an Access Denied message from mariadb after changing the password via the virtualmin UI. Possibly related to use of a $ in the password. I’d read through both issues and wasn’t sure if anyone had noticed the connection so thought I’d point it out - I haven’t experienced the issue myself.
Anyway, just to be clear, I haven’t changed my MySQL password in virtualmin in years, and everything has always worked fine. Suddenly, it stopped working after a few updates.