0

I am on Ubuntu 22.04 on WSL2 on Windows 11.

anjanesh@SOMEID:/mnt/c$ sudo service mysql start
 * Starting MySQL database server mysqld                                                                                      [ OK ]
anjanesh@SOMEID:/mnt/c$ service mysql start
 * Starting MySQL database server mysqld                                                                                             Password:
su: Authentication failure

sudo mysql --user=root -p works but mysql --user=root -p gives :

Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (13)

1 Answer 1

0

This is not a MySQL-specific issue, this is more a Linux thing. Assuming you have a standard MySQL-Linux installation when you invoke command "MySQL" you are actually executing a program (MySQL client) located in /usr/bin/.

So, if you can't execute /usr/bin/mysql from other than root is because of permissions.

To fix it and allow any user to execute /usr/bin/mysql you have to use sudo one more time

sudo chmod +x /usr/bin/mysql

Then you should be able to execute MySQL from any user.

1
  • Still doesn't work - mysql --user=admin -p Enter password: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (13) - but with sudo it works - and I even tried creating a new user admin granting all privileges just incase logging as mysql root isnt allowed without sudo - still no avail.
    – anjanesh
    Feb 18, 2023 at 2:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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