waydeshepard's avatar

Homebrew Mysql Install Error

Hello,

I am trying to install mysql through home brew and it successfully installs, the i run the mysql -u root (Not using a password.) and i get an error saying:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
0 likes
6 replies
ejdelmonico's avatar

Is mysql starting properly when you run /usr/local/bin/safe_mysqld?

If so:

Verify the /tmp/mysql.sock file exists.

If not do:

touch /tmp/mysql.sock

// With old brew recipes
safe_mysqld restart
// With new brew recipes
mysqld_safe restart

//If mysql does not start properly after that last line:

/*You may need to install the tables manually using /usr/local/bin/mysql_install_db, then restart mysql.*/

//From stack overflow
waydeshepard's avatar

@ejdelmonico When i try mysqld_safe restart I get the following output:

2016-06-01T03:59:14.6NZ mysqld_safe Logging to '/usr/local/var/mysql/user.local.err'.
2016-06-01T03:59:14.6NZ mysqld_safe Starting mysqld daemon with databases from /usr/local/var/mysql
2016-06-01T03:59:14.6NZ mysqld_safe mysqld from pid file /usr/local/var/mysql/user.local.pid ended
ejdelmonico's avatar

It seems like a permissions issue to me. Try getting more info with brew info mysql

ejdelmonico's avatar

You can try changing permissions:

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

//or some folks have had success with this:
brew remove mysql
brew cleanup --force
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
sudo rm -rf /usr/local/var/mysql

brew install mysql
mysqld --initialize --explicit_defaults_for_timestamp
mysql.server start # no sudo!```
waydeshepard's avatar

When i do all that it leads to this error:

ERROR! The server quit without updating PID file (/usr/local/var/mysql/user.local.pid)
MaverickChan's avatar
Level 47

don't use home-brew to install mysql , for it has some problem in Mac OS X 10.10 and 10.11.

Try downloading mysql 5.7 directly from the website , then install mysql using the dmg.

remember , mark the temp root password , you will need it .

Please or to participate in this conversation.