Problem
$mysql -uroot -p
Enter password:
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)
Reason
in my.cnf , lower_case_table_names
is set to 0 (0-linux, 1-windows, 2-mac)
Solution
1 vi /usr/local/etc/my.cnf
# Default Homebrew MySQL server config
[mysqld]
# Only allow connections from localhost
bind-address = 127.0.0.1
lower_case_file_system = ON
ower_case_table_names = 2
2 stop mysql:
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
3 start mysql:
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
Check mysql variables
$mysql -uroot -p
mysql> show variables like ‘lower%’;
±-----------------------±------+
| Variable_name | Value |
±-----------------------±------+
| lower_case_file_system | ON |
| lower_case_table_names | 2 |
±-----------------------±------+
2 rows in set (0.05 sec)