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!

Forum: 
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:

/usr/lib/inithooks/bin/mysql.py

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:
/usr/lib/inithooks/bin/mysqlconf.py

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                       |    127.0.0.1

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.

Guest's picture

ERROR 1045 (28000): Access denied for user 'adminer'@' this keeps coming up after running the reconf script... You are completely locked out of mysql. Tried changing pw and still no go. Wasted two hrs setting up AWS for nothing. TKLBAM takes the backup, but fails to completely restore it on new VM. After few hours I trashed the VM. I consider it a waste of time... 
Jeremy Davis's picture

TBH, I'm not really clear what has gone wrong for you, nor even exactly what you are trying to do. It certainly sounds painful.

It sounds like you may have given up, but if you want a hand, best thing to do is to start your own thread and explain exactly what you are trying to do and what you've tried so far; I'm more than happy to help as much as I can.

Without a bit more info, it's hard to know what has gone wrong for sure, but my guess is that it's something to do with the MySQL config. You mention TKLBAM, so I'm guessing that you are trying to restore a backup. Perhaps from an earlier version of TurnKey?

When you say that you "Tried changing pw and still no go", do you mean that you logged in via commandline (as root) and ran something like this?:

mysql -u root 
mysql> SET PASSWORD FOR 'adminer' = PASSWORD('NewPassword');

If so, then that certainly should have worked (I just tested it to be 100% sure and FWIW it certainly works for me...)

As I say, if you want a hand, please start a new thread and explain which appliance(s) you are working with, exactly what you are trying to achieve and what you have tried so far.

Jeremy Davis's picture

Which version of the appliance are you using? It just occurred to me that if you are not using the latest TurnKey release, perhaps you are getting hit by the bug that hit a number of v15.0 appliances?! We rebuilt and re-released all the affected appliances but the broken ones are still on the mirror. We do plan to remove them when we do a batch cleanup, but the latest appliances are all available from the download links on the relevant appliance pages.

If you continue to have issues, please let me know.

Add new comment