I’ve got a raspberry pi with a phpmyadmin database. However I can not remember the password. I may not even have a password. I have tried various method of resetting the password but when I try

mysql -p -u root

I get an error no matter what I put in the password box. This is the error

ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/bar/run/mysqld/mysqld.sock’ (2)

Any ideas to fix? Many thanks.

  • Is your mysql process running? Try ps -ef|grep mysql or systemctl status mysql if you're on a systemd version of Ubuntu. – Jos May 11 at 13:08
  • @Jos I got ‘’’Unit mysqll.service could not be found’’’ – JSP May 11 at 13:18
  • Then you haven't installed mysql. – Jos May 11 at 13:23

Go go step 3 on this page. Do it.

It is the Digital Ocean solution. I have tried all other solutions and this one works every time.

You need to allow password authentication and off you go.

| improve this answer | |
  • This didn’t work. Exact same error – JSP May 11 at 13:15
  • Sorry about that. in the first command make sure you run sudo mysql and not sudo mysql -u. . . Don't specify a user. – walttheboss May 11 at 21:51

I realised I had to uninstall then reinstall phpmyadmin as I could not login and had no password. The problem is fixed now.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.