Sunday, November 16, 2008

Install mysql in PowerPC Mac Mini and make php-mysql works

The problem for mysql server in Mac OS X powerpc platform is that there is no binary build for package format (.dmg) for Leopard and the tar.gz binary does not work with the default php5 which uses the unix socket at /var/mysql/mysql.sock plus there is no LaunchDaemon plist. Either you have to change the etc/php.ini or build the mysql server from source.

This guide shows how to build from source

(1) Choose the mirror site and download the source tar.gz file

(2) untar and unzip it

tar -xzvf mysql-5.1.29-rc.tar.gz

(3) config, make and install (make sure you have Xcode installed already)

cd mysql-5.1.29-rc

scipt: Select all

CC=gcc CFLAGS="-O3 -fno-omit-frame-pointer" CXX=gcc CXXFLAGS="-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-unix-socket-path=/var/mysql/mysql.sock \

sudo make install

(4) create database

sudo chgrp -R mysql /usr/local/mysql
cd /usr/local/mysql
sudo ./bin/mysql_install_db --user=mysql
sudo chown -R mysql ./var

(5) create unix-socket directory

sudo mkdir -p /var/mysql
sudo chown -R mysql /var/mysql

(6) create LaunchDaemons in /Library/LaunchDaemons/com.mysql.mysqld.plist so that it can autostart

sudo vi /Library/LaunchDaemons/com.mysql.mysqld.plist

and put this in the file

com.mysql.mysqld.plist: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">

(7) start mysql server and restart apache server

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

and if you want to manually stop the mysql server

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

(8) create path in ~/.bash_login

vi ~/.bash_login

and put this

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

run this

. ~/.bash_login

(9) create root password with mypassword
mysqladmin -u root password mypassword

(10) create databse in mysql

mysql -u root -p
> CREATE DATABASE database_name DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
> GRANT ALL PRIVILEGES ON database_name.* TO username@localhost IDENTIFIED BY 'password';

No comments: