0

I have been fighting against this error ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

and somehow just reproduced it by simply failing to login properly.

$ mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

$ mysql -uroot
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

$ mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

What's going on here?

Anthony
  • 13,434
  • 14
  • 60
  • 80
  • it looks like your MySQL server is not running... Did you check? – ultrajohn Feb 18 '17 at 06:01
  • The server is definitely running. Unless failing to login to it crashed it? – Anthony Feb 18 '17 at 06:01
  • Though it looks like it's still up. – Anthony Feb 18 '17 at 06:02
  • Can you try passing a host parameter value in the mysql command like `mysql -u root -h localhost` or 127.0.0.1 – ultrajohn Feb 18 '17 at 06:04
  • It looks like passing the host as 127.0.0.1 works After shutting down mongod and rebooting it I get ```2017-02-18T06:07:37.988579Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 35 2017-02-18T06:07:37.988604Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.``` Do you know what's going on? – Anthony Feb 18 '17 at 06:08
  • if using `localhost` host option does not work, then could be that the `127.0.0.1 localhost` entry in your system's `hosts` file is missing, hence `localhost` is not being resolved correctly. – ultrajohn Feb 18 '17 at 06:11
  • I already checked that and it's in my hosts file. Do you know about this data lock error? Getting it nonstop – Anthony Feb 18 '17 at 06:12
  • then i'm mistaken, check this out this related so post http://stackoverflow.com/questions/16325607/cant-connect-to-local-mysql-server-through-socket-tmp-mysql-sock – ultrajohn Feb 18 '17 at 06:19
  • I'm using OS X I don't have the service binary – Anthony Feb 18 '17 at 06:19
  • How can I stop the mongod process in OS X ? Everything I try gives me this lock error – Anthony Feb 18 '17 at 06:20
  • Can you try doing a `service mysql stop` and `service mysql start` and see if it helps. The idea is to make sure that there is only one MySQL server instance running in your machine for a particular config file. – ultrajohn Feb 18 '17 at 06:21
  • anyway, i think it would be best if you create a separate SO post for that. :) Good luck! – ultrajohn Feb 18 '17 at 06:22
  • Like I said, on OS X we don't have a service binary. `bash: service: command not found` – Anthony Feb 18 '17 at 06:22

0 Answers0