This guide shows how to build from source
(1) Choose the mirror site and download the source tar.gz file
http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.29-rc.tar.gz/from/pick#mirrors
(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 \
--with-mysqld-user=mysql
make
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" "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>
(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';
> FLUSH PRIVILEGES;
> QUIT
No comments:
Post a Comment