Feb 10, 2009
Mac OS X に MySQL をインストール
Mac OS X に MySQL をインストールしたときの手順をメモ。 参考にさせていただいたサイトは以下の通り。感謝!!
- forever 5 years old blog - MacPorts で MySQL をインストールしてみる
- http://www.forever5yearsold.net/archives/72
- setup_osx - bear-project - PHP5環境構築(OSX macports)
- http://code.google.com/p/bear-project/wiki/setup_osx
- F.Ko-Ji の「一秒後は未来」 - MacPortsでのMySQLインストールで初歩的ミス
- http://blog.fkoji.com/2008/05041648.html
MacPorts で MySQL をインストール
$ sudo port install mysql5 +server ---> Fetching mysql5 ---> Verifying checksum(s) for mysql5 ---> Extracting mysql5 ---> Configuring mysql5 ---> Building mysql5 with target all ---> Staging mysql5 into destroot ---> Creating launchd control script ########################################################### # 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.67_0+server ****************************************************** * In order to setup the database, you might want to run * sudo -u mysql mysql_install_db5 * if this is a new install ****************************************************** ---> Activating mysql5 5.0.67_0+server ---> Cleaning mysql5 $
MySQL の初期化
$ sudo -u mysql mysql_install_db5 Password: Installing MySQL system tables... 090210 13:45:50 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295 090210 13:45:50 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295 090210 13:45:50 [Warning] option 'thread_stack': unsigned value 65536 adjusted to 131072 090210 13:45:50 [Warning] Setting lower_case_table_names=2 because file system for /opt/local/var/db/mysql5/ is case insensitive OK Filling help tables... 090210 13:45:50 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295 090210 13:45:50 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295 090210 13:45:50 [Warning] option 'thread_stack': unsigned value 65536 adjusted to 131072 090210 13:45:50 [Warning] Setting lower_case_table_names=2 because file system for /opt/local/var/db/mysql5/ is case insensitive OK To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: /opt/local/lib/mysql5/bin/mysqladmin -u root password 'new-password' /opt/local/lib/mysql5/bin/mysqladmin -u root -h watashi-nokonpyuta.local password 'new-password' Alternatively you can run: /opt/local/lib/mysql5/bin/mysql_secure_installation which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers. See the manual for more instructions. You can start the MySQL daemon with: cd /opt/local ; /opt/local/lib/mysql5/bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl cd mysql-test ; perl mysql-test-run.pl Please report any problems with the /opt/local/lib/mysql5/bin/mysqlbug script! The latest information about MySQL is available on the web at http://www.mysql.com Support MySQL by buying support/licenses at http://shop.mysql.com $
MySQL の設定
$ sudo cp /opt/local/share/mysql5/mysql/my-small.cnf /etc/my.cnf $ sudo vi /etc/my.cnf $ sudo diff /opt/local/share/mysql5/mysql/my-small.cnf /etc/my.cnf 21a22 > default-character-set = utf8 71a73,74 > default-character-set = utf8 > 74a78 > default-character-set = utf8 $ sudo mkdir /opt/local/var/run/mysql5 $ sudo chown mysql:mysql /opt/local/var/run/mysql5/ $ sudo chmod 755 /opt/local/var/run/mysql5
MySQL の起動
$ sudo /opt/local/share/mysql5/mysql/mysql.server start Starting MySQL.. SUCCESS!
DB、ユーザの作成
$ mysql5 -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or ¥g. Your MySQL connection id is 7 Server version: 5.0.67 Source distribution Type 'help;' or '¥h' for help. Type '¥c' to clear the buffer. mysql> create database mydb; Query OK, 1 row affected (0.01 sec) mysql> grant all privileges on *.* to me@localhost identified by 'mypass' with grant option; Query OK, 0 rows affected (0.00 sec) mysql> ¥q Bye
MySQL のアンインストール
$ sudo port uninstall mysql5 $ sudo rm -rf /opt/local/var/db/mysql5
TrackBack ping me at
http://www.in-vitro.jp/blog/index.cgi/MySQL/20090210_01.trackback
writeback message: Ready to post a comment.
