設定編集
文字コードをUTF-8に変更します。
# vi /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
old_passwords=1
#default-character-set=utf8 //5.5以前
character-set-server = utf8 //5.5以降
skip-character-set-client-handshake //追加
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
#default-character-set=utf8 //5.5以前
character-set-server = utf8 //5.5以降
skip-character-set-client-handshake // 追加
起動
# /etc/init.d/myslqd start
MySQL Daemon failed to start.
mysqld を起動中: [失敗]
再インストールしてみたり、mysqlのプロセスが生きてないか確認してみたが、原因がわからないため、一端、mysql関連を削除
# yum -y remove php php-cli php-pdo php-mysql php-common php-mbstring
# yum -y remove mysql-libs mysql-server mysqlclient15 mysql-devel perl-DBD-mysql mysql
# rm -rf /var/lib/mysql //これ重要
再度、インストール
# yum --enablerepo=remi,epel install php php-mbstring php-mysql mysql-server
再度、起動
# /etc/init.d/mysqld start
........
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h www5087u.sakura.ne.jp password 'new-password'
mysqld を起動中: [ OK <span style="color: #444444; line-height: 24px; white-space: normal; font-size: 16px;">]</span>
Baseのパッケージとremiパッケージで混在してたのが原因かと。
自動起動の設定
起動が確認できたら、chkconfigコマンドで自動起動をON
# chkconfig mysqld on
rootパス設定
# /usr/bin/mysqladmin -u root password 'new-password'
# /usr/bin/mysqladmin -u root -h www50xxu.sakura.ne.jp password 'new-password'
#mysql -u root -p //確認
外部DBをインポートした場合の注意
# mysql -u root -p
mysql> show databases;
| information_schema |
| #mysql50#hoge_database |
| mysql
先頭に#mysql50が付いた場合には、DBのデータも5.1用にアップデートしなくてはならないようです。
# mysql_upgrade
名前が空白のユーザを削除
# mysql -u root -p
mysql> use mysql;
mysql> DELECT host,user,password from user;
+-----------------------+------+-------------------------------------------+
| host | user | password |
+-----------------------+------+-------------------------------------------+
| localhost | root | *8C56961DFE6D |
| www50xxu.sakura.ne.jp | root | *8C56961DFE6D |
| 127.0.0.1 | root | *8C56961DFE6D|
| localhost | | |
| www50xxu.sakura.ne.jp | | |
+-----------------------+------+-------------------------------------------+
mysql> DELETE FROM user WHERE user='';
mysql> ¥q
データベースの作成 (wordpressの場合)
赤字を適宜変更してください
# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 94947
Server version: 5.5.34 MySQL Community Server (GPL) by Remi
mysql> create database wordpress default character set utf8;
Query OK, 1 row affected (0.00 sec)
mysql> grant all privileges on wordpress.* to user@localhost identified by 'パスワード';
Query OK, 0 rows affected (0.00 sec)