Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

After I've done a full restart, my Apache PHP server doesn't connect to Local MySQL ( connecting via 127.0.0.1 because localhost for some reason fails always ).

So I did this today:

➜  ~ mysqladmin shutdown -u root -p
Enter password:
➜  ~ mysqladmin shutdown -u root -p
Enter password:
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!

Which basically means that I succeeded in shutting down mysql. But as soon as I did - Apache PHP successfully connect to MySQL and my local sites work without a hiccup until the next restart.

Here are a few other details: (as you can tell - I've installed MySQL via brew)

➜  ~  sudo ps aux | grep mysql
N               4774   0.0  0.0  2432768    620 s000  S+    9:53AM   0:00.00 grep mysql
N               4772   0.0  2.6  3030168 440688   ??  S     9:51AM   0:00.29 /usr/local/Cellar/mysql/5.6.13/bin/mysqld --basedir=/usr/local/Cellar/mysql/5.6.13 --datadir=/usr/local/var/mysql --plugin-dir=/usr/local/Cellar/mysql/5.6.13/lib/plugin --bind-address=127.0.0.1 --log-error=/usr/local/var/mysql/N.local.err --pid-file=/usr/local/var/mysql/N.local.pid
N               4686   0.0  0.0  2433432   1000   ??  S     9:51AM   0:00.01 /bin/sh /usr/local/opt/mysql/bin/mysqld_safe --bind-address=127.0.0.1
N               4362   0.0  2.7  3120276 458728   ??  S     9:47AM   0:00.45 mysqld


➜  ~  lsof -i | grep mysql
mysqld    4362    N   16u  IPv6 0x76959e40691f9f93      0t0    TCP *:mysql (LISTEN)

This is the weird thing:

➜  ~  killall -9 mysqld

MySQL Is dead! Apache doesn't connect. Then, when I run:

➜  ~  sudo mysqladmin shutdown -u root -p
Enter password:

Apache is (again) able to successfully connect to MySQL.

As far as I understand this means that I have two mysql servers setup and both of them are trying to start up at the same time, but I don't have the slightest idea on how to fix it. I've tried brew reinstalling but that didn't help.

➜  ~  which mysqladmin
/usr/local/bin/mysqladmin
➜  ~  whence -p mysql
/usr/local/bin/mysql

Solution:

Step 1 from http://stackoverflow.com/questions/1436425/how-do-you-uninstall-mysql-from-mac-os-x

sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
vim /etc/hostconfig and removed the line MYSQLCOM=-YES-
rm -rf ~/Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /var/db/receipts/com.mysql.*
share|improve this question

1 Answer 1

I would recommend checking to see which launch daemons you've got setup in /Library/LaunchDaemons...I'm not sure what brew uses to configure startup items, but on Mac OS X, launchd is the current recommendation. If you find something related to MySQL in /Library/LaunchDaemons, you can unload it with a command similar to:

sudo launchctl unload /Library/LaunchDaemons/com.example.plist

Previous versions (10.5;10.6) of Mac OS X included MySQL, which was installed into the /System/Library/LaunchDaemons folder:

sudo launchctl unload /System/Library/LaunchDaemons/org.mysql.mysqld.plist

If you've installed versions of MySQL from Oracle/Sun, you may still have a MySQL StartupItem at /Library/StartupItems. It should be possible to stop that service like so:

sudo /Library/StartupItems/MySQLCOM/MySQLCOM StopService

Outside of that, there shouldn't be many other places that you'd need to look...

share|improve this answer
    
Hey Eddie. No luck :( - I've updated my response listing out the Launch Daemons I could find. I remember when installing MySQL I put the homebrew.mxcl.mysql.plist there myself from homebrew setup instructions - otherwise - I see no mysql daemons anywhere. Is there some other place I can look ? –  Norris Oct 18 '13 at 12:17
    
Turns out I already fixed the issue. Editing my original post again. –  Norris Oct 18 '13 at 12:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.