MYSQL installs trivially on a mac using the packages downloadable from the mysql web site. I therefore did not follow this installation path 😉
Under the hood OSX is BSD, to this end many unix packages have been ported to OSX. The easiest way to install and manage these is via darwin ports http://www.darwinports.com . I want to play with some CMS software that requires php5 and mysql. Rather than try to manage this all by hand I installed Dports and dumped mysql apache2 and php5. Apache was pretty simple, mysql has proved harder.
Firstly we have to find the package
sudo port search mysql
This tells me I want to install mysql5, next check for varients (build options and integration options)
sudo port variants mysql5
This lists:
universal
darwin_8
server
I have _NO_ idea what these mean so a quick google sends me to http://mysql5.darwinports.com Now I still don’t know what this means but at least I know what compile options are targeted by each variant. Reading the server ‘stuff’ it talks about setting up users and files to allow it to run at system startup .. this all makes sense so to the install
sudo port install -v mysql5 +server
Now time for a brew .. tic tic tic
Notable bits of stuff spurged from the installer:
###########################################################
# A startup item has been generated that will aid in
# starting mysql5 with launchd. It is disabled
# by default. Execute the following command to start it,
# and to cause it to launch at startup:
#
# sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist
###########################################################
—> Installing mysql5 5.0.45_0+darwin_8+server
******************************************************
* In order to setup the database, you might want to run
* sudo -u mysql mysql_install_db5
* if this is a new install
******************************************************
So first of all looking a the startup item. LaunchD is an osxism that allows you to start stuff when stuff happens, (on instance of stuff is the system starts up). Its used to startup key services. To see what services run:
sudo launchctl list
I dont see mysql5 so running
sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist
Will install the service. OK so now lets try and start the service (pah like this will work!)
sudo launchtl start org.macports.mysql5
No feedback suggests its not running?! OK lets try killing it
sudo launchtl stop org.macports.mysql5
Again no feedback, is that good? ok so a restart and then try to initiate the DM from the blurb that ports printed out:
sudo -u mysql mysql_install_db5
Blah crash and burn…
Boris:/opt/local scott$ sudo -u mysql mysql_install_db5
Installing MySQL system tables…
070801 11:57:41 [Warning] Setting lower_case_table_names=2 because file system for /opt/local/var/db/mysql5/ is case insensitive
ERROR: 1005 Can’t create table ‘db’ (errno: 13)
070801 11:57:41 [ERROR] Aborting
ls – in /opt/local/var/db/mysql5 finds a few dirs owned by root .. hmm should I remove or chown them ?? Remove seems sensible.
OK so rerunning the command .. lots of crap is printed .. but *erm* no errors!
Next job setup some passwords..
/opt/local/lib/mysql5/bin/mysqladmin -u root password ‘new-password’
/opt/local/lib/mysql5/bin/mysqladmin -u root -h host94.msm.che.vodafone password ‘new-password’
It says you can start the daemon with:
cd /opt/local ; /opt/local/lib/mysql5/bin/mysqld_safe &
I thought the launchd would do this?! Ho hum.
It also notes that there are some tests you can run:
cd mysql-test ; perl mysql-test-run.pl
First job, passwords erm or not!
error: ‘Can’t connect to local MySQL server through socket ‘/opt/local/var/run/mysql5/mysqld.sock’ (2)’
Check that mysqld is running and that the socket: ‘/opt/local/var/run/mysql5/mysqld.sock’ exists!
So lets try and start mysql per the instruction:
cd /opt/local ; /opt/local/lib/mysql5/bin/mysqld_safe &
(adding a -u mysql for good measure!)
OK so I have a process running .. doing the password thing (again) .. raa no errors!
Next test, install the mysql admin packages from the web and try to connect to the local instance. NOPE! Failed to connect through socket /tmp/mysql.sock. Changing to connect via 127.0.0.1 and stuff connects?!?! OK so thats odd but I guess there is a short circuit for localhost.
OK next question, will mysql5 still be there after a reboot?! Lets find out …. …. back soon!