ツムラ_メモ

大失敗を繰り返す。

WordPressを使いたい。

研究室にある共有PCでCMSとしてWordPressを使いたいなぁと思い、適当に作業中。
MySQLが必要ということなので、インストール方法を考えたが、もうMacPortsでよくね?とか思い適当に作業してみることにする。
PHPから管理するソフトェアもあるみたいなのだけれども、セキュリティー的に怪しいなぁと思いMac Portsでインストールしてみることにする。

sh-3.2# port install mysql5-server

      • > Fetching mysql5
      • > Attempting to fetch mysql-5.0.83.tar.gz from http://mysql.he.net/Downloads/MySQL-5.0/
      • > Attempting to fetch mysql-5.0.83.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.0.83_0
      • > Activating mysql5 @5.0.83_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 launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist
###########################################################

      • > Installing mysql5-server @5.0.83_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.0.83_0
      • > Cleaning mysql5-server

sh-3.2# launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist

sh-3.2# sudo -u mysql mysql_install_db5
Installing MySQL system tables...
091103 18:53:21 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
091103 18:53:21 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
091103 18:53:21 [Warning] Setting lower_case_table_names=2 because file system for /opt/local/var/db/mysql5/ is case insensitive
OK
Filling help tables...
091103 18:53:21 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
091103 18:53:21 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
091103 18:53:21 [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 koinoji.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

ルートパスワードの設定

上述のメッセージにあるようにrootパスワードを設定しようと思ったのだが、下記のエラーで失敗。
どうもMySQLサーバーを起動させていなかったのが原因のようだ。

sh-3.2# /opt/local/lib/mysql5/bin/mysql_secure_installation




NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!


In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/opt/local/var/run/mysql5/mysqld.sock' (2)
Cleaning up...

MySQLサーバーの起動

というわけで下記のコマンドを実行させて無事にサーバーが起動した。
再度rootパスワードなどの設定を行うスクリプトを実行させる。
今度は上手くいったようだ。

sh-3.2# sudo /opt/local/share/mysql5/mysql/mysql.server start
Starting MySQL
. SUCCESS!

rootパスワードの設定(mysql_secure_installationの実行)

このスクリプトはrootパスワードを設定するだけでなく、セキュリティー上問題になりそうな部分を設定できる便利なスクリプト。
細々と設定するよりも新規インストールだったら、このスクリプトを実行させて設定してしまう方が明らかに楽そうでござる。

sh-3.2# /opt/local/lib/mysql5/bin/mysql_secure_installation




NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!


In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!


By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y
... Success!

Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y
... Success!

By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] n
... skipping.

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y
... Success!

Cleaning up...



All done! If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!


とりあえず、これでMySQLのインストールと初期設定は終わったはず。
あとはWordPress用のデータベースやらを作成してやればよいはず。