-1

I have run into a very common problem while setting up a lamp stack in ubuntu. The problem that I got into is, I try to log into phpmyadmin using 'root' as username and a password that I set during instillation, I don't know if the password is wrong or I forget or something else went wrong, any way I can't login. Now I search For the solution to reset the mysql password and I get the most suggested solution which is like below:

  sudo /etc/init.d/mysql stop
  sudo mysqld_safe --skip-grant-tables &
  sudo mysql -u root

And during this third step I get the error like below:

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

And Now I am stuck here, And I cannot reset password: So Help me

Marc Delisle
  • 8,879
  • 3
  • 29
  • 29
Surya Neupane
  • 906
  • 10
  • 20
  • Possible duplicate of [ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)](https://stackoverflow.com/questions/11657829/error-2002-hy000-cant-connect-to-local-mysql-server-through-socket-var-run) – Ken White Sep 26 '18 at 12:49
  • Its not duplicate first try to understand my question. – Surya Neupane Sep 27 '18 at 05:08
  • Starting and stopping doesnot solve the problem as given in the question that you have marked as a already asked one. – Surya Neupane Sep 27 '18 at 07:26

2 Answers2

0

In /etc/my.cnf, the socket file config may be /tmp/mysql.sock and in /etc/mysql/my.cnf the socket file config may be /var/run/mysqld/mysqld.sock.

So, remove or rename /etc/mysql/my.cnf, let MYSQL use /etc/my.cnf, then the problem may be solved.

Roy G
  • 901
  • 10
  • 25
hari babu
  • 1
  • 2
0

For me stopping and starting mysql did not help ('sudo /etc/init.d/mysql stop', 'sudo /etc/init.d/mysql start') Because I had to use the command to stop mysql: sudo /etc/init.d/mysql stop and then run other commands sudo mysqld_safe --skip-grant-tables & sudo mysql -u root before starting mysql: sudo /etc/init.d/mysql start

But simply restarting my system that is my laptop solved my problem.

Surya Neupane
  • 906
  • 10
  • 20