続いてデータベース、MySQLをインストールします。
まずはデフォルトのMySQLの確認。
$ mysql -v -bash: mysql: command not found $ ps ax | grep mysql
あれ?デフォルトでMySQLは入ってなかったかな??
ではMacPortsでインストールできるMySQLバージョンの確認。
$ port search mysql ・・・ mysql4 @4.1.22 (databases) Multithreaded SQL database server mysql5 @5.1.51 (databases) Multithreaded SQL database server mysql5-devel @5.5.2-m2 (databases) Multithreaded SQL database server mysql5-server @5.1.51 (databases) Multithreaded SQL database server mysql5-server-devel @5.5.2-m2 (databases) Multithreaded SQL database server ・・・
インストール時に指定できる variants を確認
$ port variants mysql5-server mysql5-server has no variants
mysql5-serverをインストールします。
$ sudo port install mysql5-server ・・・ ########################################################### # A startup item has been generated that will aid in # starting mysql5-server with launchd. It is disabled # by default. Execute the following command to start it, # and to cause it to launch at startup: # # sudo port load mysql5-server ########################################################### ---> Installing mysql5-server @5.1.51_0 ****************************************************** * In order to setup the database, you might want to run * sudo -u _mysql mysql_install_db5 * if this is a new install ****************************************************** ・・・
mysql5-serverをloadしてください。とのこと。
言われるままに、mysql5-serverをloadしてみます。
$ sudo port load mysql5-server
お次も言われるまま
$ sudo -u _mysql mysql_install_db5 Installing MySQL system tables... OK Filling help tables... 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 macmini.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 /opt/local/mysql-test ; perl mysql-test-run.pl Please report any problems with the /opt/local/lib/mysql5/bin/mysqlbug script!
パスワードを設定してください。とのことです。
$ sudo /opt/local/lib/mysql5/bin/mysqladmin -u root password 'new-password' /opt/local/lib/mysql5/bin/mysqladmin: connect to server at 'localhost' failed error: 'Can't connect to local MySQL server through socket '/opt/local/var/run/mysql5/mysqld.sock' (2)' Check that mysqld is running and that the socket: '/opt/local/var/run/mysql5/mysqld.sock' exists!
おっと?connectがつながらないですって!
とりあえず起動してみることに
$ sudo /opt/local/share/mysql5/mysql/mysql.server start Password: Starting MySQL . SUCCESS!
もいちどトライ
$ sudo /opt/local/lib/mysql5/bin/mysqladmin -u root password 'new-password'
今度はうまく通ったみたい。
ログインしてみる
$ /opt/local/lib/mysql5/bin/mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.1.51 Source distribution Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. This software comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to modify and redistribute it under the GPL v2 license Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
「mysql5」コマンドで操作できるみたい。
$ sudo port install mysql5-server Password: ---> Computing dependencies for mysql5-server ---> Dependencies to be installed: mysql5 ---> Fetching mysql5 ---> Attempting to fetch mysql-5.1.51.tar.gz from http://distfiles.macports.org/mysql5 ---> Verifying checksum(s) for mysql5 ---> Extracting mysql5 ---> Applying patches to mysql5 ---> Configuring mysql5 ---> Building mysql5 ---> Staging mysql5 into destroot ---> Installing mysql5 @5.1.51_0 The MySQL client has been installed. If you also want a MySQL server, install the mysql5-server port. ---> Activating mysql5 @5.1.51_0 ---> Cleaning mysql5 ---> Fetching mysql5-server ---> Verifying checksum(s) for mysql5-server ---> Extracting mysql5-server ---> Configuring mysql5-server ---> Building mysql5-server ---> Staging mysql5-server into destroot ---> Creating launchd control script ########################################################### # A startup item has been generated that will aid in # starting mysql5-server with launchd. It is disabled # by default. Execute the following command to start it, # and to cause it to launch at startup: # # sudo port load mysql5-server ########################################################### ---> Installing mysql5-server @5.1.51_0 ****************************************************** * 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-server @5.1.51_0 ---> Cleaning mysql5-server
投稿日: