My Issues is that when I am logged in as a normal user on unix server and then try to login as MySQL root. It throws below error but when I am logged in as root to unix server and then try to connect to MySQL command line it allows me. I don't understand why is this happening. and how to resolve it. I want connect to MySQL command line with any normal unix user not root always. -sh-4.2$ mysql -u root -pPASSWORD ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13)

-sh-4.2$ su Password: [root@hostname]# mysql -u root -pPASSWORD Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 78203 Server version: 5.5.52-log MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


  • SHOW GRANTS FOR root@localhost;
    – Rick James
    Sep 18, 2019 at 23:30
  • mysql> SHOW GRANTS FOR root@localhost; | GRANT ALL PRIVILEGES ON . TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*6387BE4D4543B920AB5F071F60' WITH GRANT OPTION | | GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION | +----------------------------------------------------------------------------------------------------------------------------------------+ 2 rows in set (0.00 sec)
    – aroosh
    Sep 19, 2019 at 10:36
  • same grants are there on other servers but I am able to login to MySQL command line on other server as a non-root unix user.
    – aroosh
    Sep 19, 2019 at 10:37


Your Answer

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

Browse other questions tagged or ask your own question.