Monday, March 28, 2011

Mysql Installation on Snow Leopard

Hi this is my second tech-blog,may be you have checked my first blog http://railsappmadeeasy.blogspot.com.

This blog is a guide for installation of mysql on snow leopard osx. Snow leopard has issue with mysql 5.5.10 so we need the mysql 5.1.56(X86_64)for intel architecture 64 bit machine.Let's start installation by using the following procedure.

Mysql installation on Imac machine (make sure Xcode is already installed on your machine)

If you already have installed mysql on your machine then you need to uninstall it first, To uninstall mysql from your machine use the following procedure
first Stop the mysql server from system preference & backup your databases using mysqldump
# 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-
# sudo rm -rf ~/Library/PreferencePanes/My*
# sudo rm -rf /Library/Receipts/mysql*
# sudo rm -rf /Library/Receipts/MySQL*

Download dmg(5.1.56 x86_64) for mysql from http://www.mysql.com/downloads/mysql/5.1.html#downloads
make sure it is a x86,64 bit dmg file
ones it got downloaded double click the dmg file
you can see 4 choices click on .pkg file of mysql & follow the instructions
ones .pkg file got installed, double click the mysql.preference pane to install the pane in system preference pane follow the instruction
after this install the startupackage for the mysql.
this will install mysql completly on your machine
After this follow the instruction below
open terminal & paste the command below (make sure you have Text Mate installed on your machine)

#> mate ~/.bash_login

It will open a .bash_login file, paste the below two lines at the end of this file

export PATH=/opt/local/bin:/opt/local/sbin:$PATH
export MANPATH=/opt/local/share/man:$MANPATH

#>. ~/.bash_login (This command will return empty prompt)

After doing this goto
http://www.macports.org/install.php
(MacPorts-1.9.2-10.6-SnowLeopard.dmg)
& install MAC ports
This one is the magic command don't forget this

#> sudo env ARCHFLAGS="-arch x86_64" gem install --no-rdoc --no-ri mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

It will install mysql gem for the x86_64 architecture mac & your now ready to go with mysql



some times mysql doesn't respond as per plan mainly it gives error like mysql:command not found to overcome this problem we can use the following procedure

go to the
# cd /usr/local/mysql/bin folder
then use # ./mysql -u root -p
# Enter Password:
mysql>
Now we need to set a root password we use the following command on mysql prompt
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpwd');

& it will work. This error is due to mysql couldn't find the exact path of the mysql installation so we need to follow the above mentioned procedure.