Welcome to Delicate template
Header
Just another WordPress site
Header

Installing MySQL on Snow Leopard

December 6th, 2009 | Posted by Michaël in ICT | Mac | Web Development

Just got my new MacPro this weekend. After installing my common applications, I had to install my develoment tools as well. These are the instructions to install MySQL 64-bit version on OS X Snow Leopard.

First of all, note that we are going to install MySQL compiling from source. So make sure you have installed Xcode tools and you know your way around Terminal ;)

Now lets set up our personal profile where we declare our path variable. Fire up Terminal and create/edit your profile file:

vi ~/.profile

Set your path variable like this:

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

Close and save the file. Now load the the path variable to your current shell:

source ~/.profile

Now verify your updated path:

echo $PATH

You should see /usr/local/bin at the beginning of the line returned by the system.

Now lets download the MySQL source and start compiling like crazy :

curl -0 http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.41.tar.gz/from/http://mysql.easynet.be/
 
tar xzvf mysql-5.1.41.tar.gz
cd mysql-5.1.41
CC=gcc CFLAGS="-arch x86_64 -O3 -fno-omit-frame-pointer" CXX=gcc CXXFLAGS="-arch x86_64 -O3 -fno-omit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local/mysql --with-extra-charsets=complex --enable-thread-safe-client --enable-local-infile --enable-shared --with-plugins=myisam,innobase --with-zlib-dir=bundled --with-big-tables --with-readline
 
make
sudo make install
 
cd /usr/local/mysql
sudo ./bin/mysql_install_db --user=mysql
sudo chown -R mysql ./var

Ok, everything should be compiled and installed without problems. Now lets create the launch daemon with the following content

sudo vi /Library/LaunchDaemons/com.mysql.mysqld.plits
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
 <key>KeepAlive</key>
 <true/>
 <key>Label</key>
 <string>com.mysql.mysqld</string>
 <key>Program</key>
 <string>/usr/local/mysql/bin/mysqld_safe</string>
 <key>RunAtLoad</key>
 <true/>
 <key>UserName</key>
 <string>mysql</string>
 <key>WorkingDirectory</key>
 <string>/usr/local/mysql</string>
</dict>
</plist>

Change the user to root.

sudo chown root /Library/LaunchDaemons/com.mysql.mysqld.plist

Now, to start / stop MySQL, run the these commands:

sudo launchctl load -w /Library/LaunchDaemons/com.mysql.mysqld.plist
 
sudo launchctl unload -w /Library/LaunchDaemons/com.mysql.mysqld.plist

Now the last thing todo is to set the root password:

mysqladmin -u root password "mypassword"

Now MySQL should be running smoothly and without problems on Snow Leopard.

NOTE: For the RoR mysql gem, use the following command:

sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-dir=/usr/local/mysql --with-mysql-config=/usr/local/mysql/bin/mysql_config

You can follow any responses to this entry through the RSS 2.0 You can leave a response, or trackback.

3 Responses

  • hamid says:

    Hi,
    Thanks for the guide.. I followed this article and successfully installed mysql on snow leopard but problem is I am looking for .so library files.. I need those files so I can link mysql with Qt. Although in ./configure command you mentioned –enable-shared but still it didnt show me .so lib files(.a,.la and dylib are there in lib folder).

    Can you please help me…

    Cheers,

  • D@ Mick says:

    Hi Hamid

    do you mean de library files inside the plugin folder? If you followed my steps correctly and installed mysql in the same path, you should find them in /usr/local/mysql/lib/mysql/plugin/

  • hamid says:

    Hi Dan,

    Thanks for the reply, No I mean libmysqlclient.so and libmysqlclient_r.so library files. Actually I can see some .so files in mysqllib/mysql/plugin but no libmysqclient.so file. I can see libmysqlclient.a,libmysqlclient.la and mysqlclient.dylib files in mysql/lib folder but I need libmysqlclient.so file.

    cheers,



Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">