PDA

View Full Version : Trouble installing MySQL on 10.6.8 Server



AUSMUG
15th July 2013, 09:02 PM
Fresh install of 10.6.8 Server on 2010 model MacMini
Given that no future updates will be made to the MySQL Server included in 10.6.8 Server and if I upgraded to Lion or Mountain Lion Server in the future Apple's version of MySQL would be removed from system as part of the upgrade I decided to install MySQL 5.6.12-osx10.6-x86_64 version, MySQLStartupItem.pkg and MySQL.prefPane. I now have both versions installed but have not turned on Apple's included MySQL service to avoid conflicts.

I then configured the user's Shell Environment by creating a .bash_login file and then added code using TextWrangler to set the MySQL Home environment variable to point to the root directory

export set MYSQL_HOME=/usr/local/mysql-5.6.12-osx10.6-x86_64
Added the /bin directory from the MYSQL_HOME location into your $PATH environment variable.

export set PATH=$PATH:$MYSQL_HOME/bin
Also added aliases to make it easier to manually start and stop the MySQL Daemon and check status.

alias mysqlstart="sudo /usr/local/mysql/support-files/mysql.server start"
alias mysqlstop="sudo /usr/local/mysql/support-files/mysql.server stop"
alias mysqlstatus="ps aux | grep mysql | grep -v grep"

Given that MySQL 5.6.12 installs the socket at /tmp/mysql.sock rather than Apple's default location /var/mysql/mysql.sock I changed the location in my php.ini file located at etc/php.ini to this new location in each of the 3 spots socket path was referenced, then activated the mysql5 module in Apache using Server Admin app, restarted Apache and used the MySQL.prefPane to turn on MySQL which it did with no errors. Next created and installed a phpinfo.php file on my server to check if everything looked right.

This is where I noticed my first problem. Under part of the "Configure Command" section it shows

'--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' '--with-mysql-sock=/var/mysql/mysql.sock'
which indicates it is pulling in Apple's default socket location not the MySQL 5.6.12 socket location of /tmp/mysql.sock. However in the "mysql", "mysqli" and "pdo_mysql" sections of phpinfo.php it shows the correct socket path of /tmp/mysql.sock

I then opened Terminal and entered command

which -a mysql
which returned

/usr/bin/mysql
/usr/local/mysql-5.6.12-osx10.6-x86_64/bin/mysql
this should have just returned

/usr/local/mysql-5.6.12-osx10.6-x86_64/bin/mysql

I then entered in command

mysql -uroot
which returned

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2)
It should be accessing '/tmp/mysql.sock'

However when I tried mysqlstart, mysqlstop or mysqlstatus commands in Terminal they all worked as expected.

So in summary can someone point out what mistake or omission I may have made to cause
1/ phpinfo.php to return Apple's MySQL socket path rather than the MySQL 5.6.12 socket path in the "Configure Command" section.
2/ Terminal returning both Apple's version of MySQL along with the MySQL 5.6.12 mysql location rather than just the MySQL 5.6.12 mysql location when "which -a mysql" is run.
3/ Terminal returning Apple's mysql.sock path rather than the MySQL 5.6.12 socket path when "mysql -uroot" is run.