I\'m running MAMP.
It has been working fine up until yesterday. I haven\'t been able to find anything that helps so far. But here is my problem:
As the title
I faced the same problem. When i start MAMP separately, then the problem gone. And issuing following command worked fine.
mysql -u root -p
If you'd rather avoid changing ports through MAMP or options in my.cnf file, it might be useful to try forcing a TCP connection via the following on the command line:
/Applications/MAMP/Library/bin/mysql -h 127.0.0.1 -P 8889 -u root
Remembering to set the port is important if it's anything other than the mysql default of 3306.
The -P
parameter allows you to set the port.
MAMP's default port is 8889, but you can verify what yours is set to easily via the MAMP WebStart page while MAMP is running:
http://localhost:8888/MAMP/
It'll look similar to this:
I know this is late, but if ever someone is searching this (as I was tonight, but I found the solution), here's what worked for me:
I opened MAMP and had to click "USE default Apache and MySQL ports". (80 and 3306 instead of 8888 and 8889). That seemed to fix the issue.
Silly solution... But in my case, I didnt start the mysql server. So, look that also!
Test
If you attempt to start MySQL using the full path it should work
/Applications/MAMP/Library/bin/mysql -u root -p
Fix
If that works, then you can set it to work normally by running
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock
Resolution
Now MySQL should work normally
mysql -u root -p
Mysql server has not started.
mysqld stop
mysql.server start