ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock'
It's probably because MySQL is installed but not yet running.
To verify that it's running, open up Activity Monitor and under "All Processes", search and verify you see the process "mysqld".
You can start it by installing "MySQL.prefPane".
Here is the complete tutorial which helped me: http://obscuredclarity.blogspot.in/2009/08/install-mysql-on-mac-os-x.html
You'll need to start MySQL before you can use the mysql
command on your terminal. To do this, run brew services start mysql
. By default, brew installs the MySQL database without a root password. To secure it run: mysql_secure_installation
.
To connect run: mysql -uroot
. root
is the username name here.
This happened after the homebrew install and occurs due to permission issues. The following commands fixed the issue.
sudo chown -R _mysql:mysql /usr/local/var/mysql
sudo mysql.server start