George's picture

Hi guys, I was wondering if you could help as I am quite a beginner with those things! I have the latest WordPress and turnkey linux instal and my My SQL admin password stopped working. I am trying to login from the Webmin interface and I get an error:

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

I tried changing the password from the Module config on the right by the password doesn't seem to be accepted. I have also stopped and restart the server just to make sure. Nothing seems to work. The problem is that even when I try to login with no password from the console, I get an error:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

So basically I can't even login even if there is no password. I was playing around with the database earlier on before that happens and I suspect I changed something but I am not sure why. I might have actually deleted the root account thinking it was another account I had created eariler. I read somewhere else that possibly I need to assign that account localhost access. If that's the case how could I do that from teh console or webmin?

Thanks guys, I hope you can help I am quite desperate!

Jeremy Davis's picture

As a beginner, you can be totally forgiven for getting confused, because well, it's a bit confusing...! :)

To access MySQL, you need to use the MySQL root user password to login. To clarify, that is a completely separate password to your root Linux user (although just for extra confusion, you could use the same password for both accounts if you wanted to).

Your MySQL root account definitely requires a password, AFAIK it's not possible to have a MySQL root user without a password (and if it is, it probably shouldn't be). So that explains why trying to log into MySQL from the commandline wasn't working.

You can quickly reset the password though. Try this:


Then you should be good to go.

George's picture

Thanks for getting back so quickly Jeremy. So I think the problem is that I might have deleted the root@localhost mysql user because when I listed all the users, I couldn't find that particular one even though it is present in another appliance installation. The command you listed gave me a "No such file or directory" response. I managed to sort the issue though from this post here. The only problem with this is that it removed existing users before creating this missing one but I only had to recreate a couple and connect them to their databases. The response that helped me is the one that currently has 28 votes and starts with:

for this kind of error; you just have to set new password to the root user as an admin. follow the steps as follows:

Do you think this solution might somehow damage the installation though?

Jeremy Davis's picture

It should have been:

I should have double checked instead of just going from memory, that would have saved you some hassles...

As for whether it will damage it, so long as you have set a root MySQL user password and everything still works, then I wouldn't imagine so. But if you've removed other users that were there, then chances are that you've broken something. It will depend on whether that's a problem for you or not.

In future I would strongly urge you to make a backup first. That way when this stuff happens you can just restore.

George's picture

Thanks for the command, seems to be working now. Yes you are right about the backup, it was just a local appliance installation that my IT manager had installed for me and I only had our staging website in there/ In the installation I have at home I can see three more users that were added by the system on install:

user                      |   host     


root                       |

root                       |   ::1

debian-sys-maint  |  localhost


I don't have those users now in this install. Is that a bad thing? Can I somehow recreate them?

Jeremy Davis's picture

If it's just a staging server, why not start again? It sounds like you have significantly changed things, so the best way to know you are at a known good place, would be to start again.

Having said that, you may be able to resolve the damage by re-configuring. You could also try re-installing, but that may destroy the current DB, I'm not sure. So probably as a last resort... You should be able to reconfigure like this:

dpgk-reconfigure mysql-server

Please note that's OTTOMH, so if it doesn't work, do a quick google because it will be close.

Also looking at your table, that's 2 users, root and debian-sys-maint, it's just that root is listening via IPv6 too. You should have both root and debian-sys-maint as DB users.

Add new comment