Macos – Can’t start MySQL server on OSX

macosMySQL

I just installed MySQL Server and Startup tools from the DMG at the MySQL site on an OSX 10.6.6. I restarted the computer, but it seems it can't connect to its socket.

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

I try starting the server

$ sudo /usr/local/mysql/bin/mysqld_safe &
[2] 917

But I still get

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

I can't seem to find the socket file

$ ls /tmp/mysql*
ls: /tmp/mysql*: No such file or directory
$ ls /var/lib/mysql*
ls: /var/lib/mysql*: No such file or directory

Best Answer

You must start server and add the root user.

Starting the server:

sudo /usr/local/mysql/support-files/mysql.server start , or

sudo /usr/local/mysql/bin/mysqld_safe --user=mysql & , or

sudo /Library/StartupItems/MySQLCOM/MySQLCOM start

Add root user:

/usr/local/mysql/bin/mysqladmin -u root password your_password

Related Question