仙台の山奥で自転車に乗ったり転んだり

愛車の GIOS でサイクリングしたりポタリングしたり、それをブログに記録してみたり。ロードバイクや自転車や坂のことを書いてみたり。ときたまプログラムのことを忘れないようにメモってみたり。

OSを再インストールしたVPSにデータベース(MySQLとPostgreSQL)をセットアップ

ApacheVPSの初期状態から入っているのでそのまま。
DBをまず準備する。使わないけどPostgreSQLもインストールするのは、ただの趣味。

[root@host ~]# yum install mysql mysql-devel mysql-libs mysql-server
[root@host ~]# yum install postgresql postgresql-devel postgresql-libs postgresql-server

MySQLの設定ファイルMedium(128Mバイトのメモリを持つサーバー向け)をベースに、文字コードUTF-8に設定ファイルを作成。

[root@host ~]# cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
[root@host ~]# vim /etc/my.cnf
[root@host ~]# diff -u /etc/my.cnf.org /etc/my.cnf >/etc/my.cnf.patch
[root@host ~]# cat /etc/my.cnf.patch
--- /etc/my.cnf.org     2011-03-30 21:15:30.000000000 +0900
+++ /etc/my.cnf 2011-03-30 21:22:50.000000000 +0900
@@ -20,6 +20,9 @@
 port           = 3306
 socket         = /var/lib/mysql/mysql.sock

+default-character-set = utf8
+
+
 # Here follows entries for some specific programs

 # The MySQL server
@@ -134,15 +137,24 @@
 #innodb_flush_log_at_trx_commit = 1
 #innodb_lock_wait_timeout = 50

+default-character-set=utf8
+skip-character-set-client-handshake
+character-set-server = utf8
+collation-server = utf8_general_ci
+
 [mysqldump]
 quick
 max_allowed_packet = 16M

+default-character-set=utf8
+
 [mysql]
 no-auto-rehash
 # Remove the next comment character if you are not familiar with SQL
 #safe-updates

+default-character-set=utf8
+
 [isamchk]
 key_buffer = 20M
 sort_buffer_size = 20M

MySQL自動起動を設定して、サーバを起動(MySQLのデータベースを初期化)、rootユーザのパスワードをリセット。

[root@host ~]# chkconfig --list mysqld
mysqld          0:off   1:off   2:off   3:off   4:off   5:off   6:off
[root@host ~]# chkconfig mysqld on
[root@host ~]# chkconfig --list mysqld
mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off
[root@host ~]# /etc/rc.d/init.d/mysqld start
...
[root@host ~]# mysqladmin -u root password ...