I’m working on setting up a WordPress site and need to get MySQL running on my Mac. I’m using macOS 10.10.3 and have already installed the PHP SDK for Google App Engine.
I downloaded the MySQL server package (Mac OS X 10.9 x86 64-bit TAR Archive) and extracted it to my Downloads folder. When I try to connect to MySQL using this command:
The terminal prompts me for my password, but after entering it I get this error message:
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)
I’m not sure what’s causing this connection issue. Has anyone encountered this problem before? What steps should I take to resolve this MySQL socket connection error on macOS?
lol classic mistake - mysql server isn’t running. try sudo launchctl load -w /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist if you’ve got the plist file. way easier than starting it manually every time.
Had this exact issue when I first set up MySQL on my Mac. Your MySQL server isn’t running - the socket file /tmp/mysql.sock only exists when the MySQL daemon is actively running. Since you’re using the TAR archive version, you need to start it manually. First, initialize the data directory with ./scripts/mysql_install_db from your MySQL directory, then start the server with ./bin/mysqld_safe &. Once it’s running, you’ll see the socket file appear in /tmp and your connection command will work. Also, check your path - looks like you have an extra /mysql in there.
The socket error indicates that your MySQL server is not currently active. Simply installing MySQL does not automatically initiate the server; you need to start the MySQL daemon manually. Navigate to your extracted MySQL directory and execute the command /Users/johndoe/Downloads/mysql-5.6.24-osx10.9-x86_64/bin/mysqld_safe --user=mysql &. Alternatively, if you installed MySQL as a service, you can start it from System Preferences using the MySQL preference pane or by running sudo /usr/local/mysql/support-files/mysql.server start. After starting the server, you should be able to connect without encountering the socket error. To verify if MySQL is running, you can check with ps aux | grep mysql or look for the socket file at /tmp/mysql.sock.
hey, you’re missing the mysql server start step. try using homebrew instead: run brew install mysql, then brew services start mysql. should fix those socket errors.
Had the exact same socket error with MySQL on a Laravel project. MySQL just wasn’t running, but here’s an easier fix than manually starting the daemon every time. After you extract the TAR archive, copy the startup script: sudo cp support-files/mysql.server /usr/local/bin/. Now you can start MySQL with sudo mysql.server start and it’ll create the socket file automatically. Plus it survives reboots. Also fix that double mysql path in your connection command - should be /bin/mysql not /bin/mysql/mysql. Socket error goes away once the server’s actually running.