Hello! I’ve run into a problem with MySQL and the root password. It started recently, not sure when - everything worked fine a few weeks ago.
But now when I try to add a new server, I get this error:
Failed to create virtual server : DBI connect failed : Access denied for user 'root'@'localhost' (using password: YES)
I have gone into Webmin > MySQL > Module Config, and changed some settings there. First I changed the root password, and clicked Save. It took me to a login page, but when i type the password in there, it doesn’t work. Then I set the login from Automatic to root, and tried changing the password to something else again - still no dice and it still won’t let me log in to MySQL.
I then went to double-check the settings in /etc/webmin/mysql/config. The password listed there was the last one I’d tried to change it to via Webmin - and just to experiment, I tried changing it in Webmin again, and it updated in config. So updating the password definitely works - yet it still won’t let me log in with that password as the root user. I then also tried logging in via SSH:
mysql -u root -p
but again, when I type the password in, it just gives me an incorrect username/password error.
Any ideas what might be wrong here? MySQL is up and running fine, all my sites are using it no problems - it just seems to be the root account that can’t login somehow!
Well, what you described when running this command seems to be the issue:
mysql -u root -p
So long as that doesn’t work – that means the password is unknown.
The key is to figure out what your MySQL password is currently set to… which could potentially be tricky
If you can’t determine what your password is, the next step would be to perform the steps to reset your MySQL root password. Let us know if you need those and I can look that up.
Well, I thought /etc/webmin/mysql/config would show me the password? There’s an entry in there for password, and it updates when I change it in WebMin. That’s the one I’ve been trying, but mysql won’t accept it.
Well, what’s in /etc/webmin/mysql/config isn’t the actual password, but what Webmin thinks the password is.
Now, normally, that’s also the actual password.
But in this case, when Webmin/Virtualmin tries to authenticate with MySQL, it’s not working… so that means whatever it has in /etc/webmin/mysql/config isn’t correct.
You should be able to use this guide here (it mentions Debian, but this should work on any distro) to reset your MySQL root password:
Ah - following that link you gave me, fixed it. Followed their instructions and managed to reset the password - VirtualMin is now letting me create servers again as normal!