Takuya71 のぶろぐ


CentOS6.3に mysql server 5.5 をインストール

今回は mysql 5.5 をインストールします。

remi レポジトリを登録

まずは レポジトリの追加をします。

$ sudo rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
http://rpms.famillecollet.com/enterprise/remi-release-6.rpm を取得中
警告: /var/tmp/rpm-tmp.6wdW2T: ヘッダ V3 DSA/SHA1 Signature, key ID 00f97f56: NOKEY
エラー: 依存性の欠如:
  epel-release >= 6 は remi-release-6-1.el6.remi.noarch に必要とされています

どうも epel-release ってのが必要なようです。

ググるfedora のepel-release-6-8.noarch.rpm rpm をインストールすればよいみたい

$ wget http://ftp-srv2.kddilabs.jp/Linux/distributions/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm

ダウンロードしたら rpm でインストール

$ sudo rpm -ivh epel-release-6-8.noarch.rpm 

再度 remi レポジトリの追加

$ sudo rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm


mysql5.5 のインストール

レポジトリが無事追加出来たので 次に mysql 5.5 のインストールです。

$ sudo yum --enablerepo=remi --disablerepo=base,updates install mysql mysql-server mysql-devel


Error: Package: mysql-server-5.5.29-1.el6.remi.x86_64 (remi)
           Requires: perl-DBI
Error: Package: mysql-server-5.5.29-1.el6.remi.x86_64 (remi)
           Requires: perl(DBI)
Error: Package: mysql-server-5.5.29-1.el6.remi.x86_64 (remi)
           Requires: perl-DBD-MySQL

無事インストール出来るかと思いきや 依存性のエラーが出ました。

yum でインストール

$ sudo yum install perl-DBI
$ sudo yum install perl-DBD-MySQL


$ sudo yum --enablerepo=remi --disablerepo=base,updates install mysql mysql-server mysql-devel


mysql の設定

/etc/my.cnf の編集

my.cnf に以下の設定を追記

character-set-server = utf8

default-character-set = utf8


$ sudo chkconfig mysqld on


$ sudo service mysqld start

mysql セットアップ


$ sudo mysql_secure_installation


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] n <= ちゃんと設定しておきましょう。今はテストなんで無しで(汗)
 ... skipping.

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] n <= リモートから接続したいので
 ... skipping.

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 <= test データベースはおいておく
 ... 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 -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.5.29 MySQL Community Server (GPL) by Remi

Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


mysql> show variables like 'character_set%';
| Variable_name            | Value                      |
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
8 rows in set (0.00 sec)