Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

Please Help MySQL issue

I am having trouble with the version of MySQL that I installed via:

brew install mysql

I installed version 5.5.29 but I cannot start the server without this error popping up:

[06:58:45][example@example-iMac ~]$ mysql.server start
Starting MySQL
.. ERROR! The server quit without updating PID file (/usr/local/var/mysql/example
iMac.local.pid).

When I try to check the version of MySQL I get:

[07:10:10][example@example-iMac ~]$ mysql -v
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 31
Server version: 5.5.28 MySQL Community Server (GPL)

Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Reading history-file /Users/example/.mysql_history
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

This should be version 5.5.29

I feel like I need to somehow change the PATH of the installation of MySQL. I also feel like this means that i have multiple versions of MySQL installed on this machine and I am going to try to remove these version to eleviate future confusion. I am using MySQL on my new Rails app.

11 Answers

Try opening the directory that is mentioned in the error message. And delete the *.err file/s and just manually create the file its complaining about.

This really wasn't going to fix my problem because I need to be using the MySQL instance that is in:

usr/local/cellar/mysql/5.5.29/

But for some reason my system is only finding:

usr/local/var/mysql

Also when I go into usr/local/var/mysql and try to delete the .err file and create the .pid file it erases the .err file and then the file reappears and when I create the .pid file it erases it immediately.... its weird

I really think that I need to somehow change the PATH so that it defaults to the version that Homebrew installed which is located in:

usr/local/cellar/mysql/5.5.29/

I really need some help with this issue if anyone has any thoughts!

@Billy - It looks like you may have missed a few of the install steps.

Try these directions, for how to install MySQL on Mountian Lion (OS X)

@James

I have run through these directions 3 times now and I still come up with the same error.... I feel like this is some kind of PATH issue... this is where I think the problem is but I don't know how to fix it:

My .bash_profile contains this path:

.bash_profile

export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"

It seems like this path makes it recognize a different version of MySQL.

Anytime I do:

$ which mysql
/usr/local/bin/mysql

$ mysql -v
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 31
Server version: 5.5.28 MySQL Community Server (GPL).........

This should be 5.5.29, I don't get it!

any other thoughts or suggestions?

You are seeing 2 versions, in 2 different places, because you installed 2 different versions of MySQL.

One is via the native DMG and one via brew. You need to uninstall both instances of MySQL and then re-install.


Note: If any of these commands throw a permission error, try using them with sudo

Step 1) Make sure MySQL is stopped

1a) Stop the Brew instance of MySQL:

launchctl unload -w   /Library/LaunchDaemons/org.macports.mysql.plist
launchctl load -w /Library/LaunchDaemons/org.macports.mysql.plist

1b) Stop the DMG instance of MySQL:

/usr/local/sbin/mysqlctl stop

1c) Confirm that all MySQL processes are stopped:

ps aux | grep mysqld | grep -v grep

If any processes are still there, forcefully kill those MySQL processes:

killall -9 mysqld

Otherwise, proceed to step 2


:bomb: WARNING: This is will delete any MySQL databased you have.

So, backup any data you want to keep.

Step 2) Uninstall the DMG instance

sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
edit /etc/hostconfig and remove the line MYSQLCOM=-YES-
rm -rf ~/Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /private/var/db/receipts/*mysql*

Step 3) Uninstall the homebrew instance

brew remove mysql
brew cleanup
unload homebrew.mxcl.mysql.plist
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

Step 4) Reinstall MySQL using brew instructions


Source:

uninstall DMG instance of MySQL

uninstall brew instance of MySQL

Does this mean that I have 3 instances of MySQL running on this machine?

[23:26:23][example@examples-iMac ~]$ mysql.server status
 SUCCESS! MySQL running (35572)
[23:26:27][example@examples-iMac ~]$ ps aux | grep mysqld
example        35586   0.0  0.0  2432768    596 s000  R+   11:26PM   0:00.00 grep mysqld
example        35572   0.0  0.3  2659132  43012   ??  S    11:26PM   0:00.07 /usr/local/Cellar/mysql/5.5.29/bin/mysqld --basedir=/usr/local/Cellar/mysql/5.5.29 --datadir=/usr/local/var/mysql --plugin-dir=/usr/local/Cellar/mysql/5.5.29/lib/plugin --log-error=/usr/local/var/mysql/examples-iMac.local.err --pid-file=/usr/local/var/mysql/examples-iMac.local.pid
example        35513   0.0  0.0  2433432    976   ??  S    11:26PM   0:00.01 /bin/sh /usr/local/opt/mysql/bin/mysqld_safe
[23:26:31][example@examples-iMac ~]$ mysql.server stop
Shutting down MySQL
. SUCCESS! 
[23:26:37][example@examples-iMac ~]$ mysql.server stop
Shutting down MySQL
. SUCCESS! 
[23:26:39][example@examples-iMac ~]$ mysql.server stop
 ERROR! MySQL server PID file could not be found!
[23:26:40][example@examples-iMac ~]$ ps aux | grep mysqld
example        35687   0.0  0.0  2432768    596 s000  S+   11:26PM   0:00.00 grep mysqld
[23:26:42][example@examples-iMac ~]$ 

@James- also for some reason all of the commands in step one except ps aux | grep mysqld did not work, so I could not get step 2 completed

@James I now have it to the point where it looks like I only have one instance:

[00:14:30][example@Examples-iMac ~]$ ps aux | grep mysqld
example  35993   0.0  0.0  2432768    596 s000  R+   12:14AM   0:00.00 grep mysqld

@Billy - That's not an instance of MySQL that's actually the grep command you just ran.

You can confirm that by using one:

ps aux | grep mysqld | grep -v grep

It filters grep processes out of the results.

If that returns any results you can forcefully kill those processes with killall -9 mysqld and proceed to step 2.