Search code examples
mysqlmacosgoogle-app-engineterminallocalhost

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


I am following this tutorial to setup a Wordpress website on Google cloud: https://googlecloudplatform.github.io/appengine-php-wordpress-starter-project/

  • I am working on a Mac with OSX 10.10.3.
  • I have installed the PHP SDK for Google App Engine software.

Now I am trying to install MySQL server on my mac. I have downloaded the Mac OS X 10.9 (x86, 64-bit), Compressed TAR Archive here: http://dev.mysql.com/downloads/mysql/

As the tutorial says, I am command the following line in my Terminal:

/Users/myuser/Downloads/mysql-5.6.24-osx10.9-x86_64/bin/mysql/mysql -u root -p mypassword

First the terminal asked for my password, and when I enter this the following error occurs:

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


Solution

  • It's a common error , you can fix it like this

    enter image description here

    You can remove root password with this command sequence:

    $ mysql -u root
    mysql> use mysql;
    mysql> update user set password=PASSWORD("") where User='root';
    mysql> flush privileges;
    mysql> quit