LeopardでMySQL動かす
MySQL Ver.5 をインストールする.
# sudo port install mysql5 +server .... ########################################################### # 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 ########################################################### ****************************************************** * In order to setup the database, you might want to run * sudo -u mysql mysql_install_db5 * if this is a new install ******************************************************
自動起動の登録
# sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist
- 登録から外すには,unload すればいい.
DBのパーミッション設定
# sudo chown -R mysql /opt/local/var/db/mysql5/ # sudo chgrp -R mysql /opt/local/var/db/mysql5/
設定ファイルを編集
# cp /opt/local/share/mysql5/mysql/my-small.cnf /opt/local/etc/mysql5/my.cnf # sudo vi /opt/local/etc/mysql5/my.cnf
my.cnfに以下を追加しておく.Railsの文字化け対策.
[mysqld] ... # USER-SETTINGS default-character-set = utf8 default-storage-engine = innodb skip-character-set-client-handshake
手動で起動
$ sudo mysqld_safe5 &
root パスワード設定
# mysqladmin5 -u root password 'xxxxx'
ログイン
$ mysql5 -u root -p $ /opt/local/bin/mysql5 -u root -p
root は全てパスワード設定しておく
mysql> select user,host,password from mysql.user; mysql> set password for root@'Macintosh.local'=password('xxxxx'); mysql> set password for root@127.0.0.1=password('xxxxx');
メモ
手動起動/停止
# /Library/StartupItems/MySQLCOM/MySQLCOM start # /Library/StartupItems/MySQLCOM/MySQLCOM stop $ mysqladmin5 -u root -p shutdown