久しぶりにMySQLのインストール。
この手の設定は、2年に一度くらいしかしないので覚え書き。
OS : CentOS6.7
そういえば、前回は、CentOS 5.8にMySQL5.5 をインストールしていた。
しかも yum ではなくrpmで・・・。懐かしい。
そのままで、yum install してもインストールされる対象は、MySQL5.1の為、MySQL5.6にしたい。
[bash]
yum install http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
[/bash]
パッケージ情報の確認
yum infoで、インストールするパッケージの情報を表示する
[bash]
yum info mysql-community-server
読み込んだプラグイン:fastestmirror, security
Loading mirror speeds from cached hostfile
* base: centos.usonyx.net
* extras: ftp.iij.ad.jp
* updates: centos.usonyx.net
利用可能なパッケージ
名前 : mysql-community-server
アーキテクチャ : x86_64
バージョン : 5.6.26
リリース : 2.el6
容量 : 53 M
リポジトリー : mysql56-community
要約 : A very fast and reliable SQL database server
…
[/bash]
インストール
上記で調べた利用可能なパッケージ名を指定してインストールする。
[bash]
$ yum install mysql-community-server
読み込んだプラグイン:fastestmirror, security
インストール処理の設定をしています
Loading mirror speeds from cached hostfile
* base: centos.usonyx.net
* extras: ftp.iij.ad.jp
* updates: centos.usonyx.net
依存性の解決をしています
…
依存性を解決しました
====================================================================================================
パッケージ アーキテクチャ
バージョン リポジトリー 容量
====================================================================================================
インストールしています:
mysql-community-libs x86_64 5.6.26-2.el6 mysql56-community 1.9 M
置き換えています mysql-libs.x86_64 5.1.73-5.el6_6
mysql-community-libs-compat x86_64 5.6.26-2.el6 mysql56-community 1.6 M
置き換えています mysql-libs.x86_64 5.1.73-5.el6_6
mysql-community-server x86_64 5.6.26-2.el6 mysql56-community 53 M
依存性関連でのインストールをします。:
mysql-community-client x86_64 5.6.26-2.el6 mysql56-community 18 M
mysql-community-common x86_64 5.6.26-2.el6 mysql56-community 307 k
perl-DBI x86_64 1.609-4.el6 base 705 k
トランザクションの要約
====================================================================================================
インストール 6 パッケージ
総ダウンロード容量: 75 M
これでいいですか? [y/N]
パッケージをダウンロードしています:
(1/6): mysql-community-client-5.6.26-2.el6.x86_64.rpm | 18 MB 00:05
(2/6): mysql-community-common-5.6.26-2.el6.x86_64.rpm | 307 kB 00:00
(3/6): mysql-community-libs-5.6.26-2.el6.x86_64.rpm | 1.9 MB 00:00
(4/6): mysql-community-libs-compat-5.6.26-2.el6.x86_64.rpm | 1.6 MB 00:00
(5/6): mysql-community-server-5.6.26-2.el6.x86_64.rpm | 53 MB 00:12
(6/6): perl-DBI-1.609-4.el6.x86_64.rpm | 705 kB 00:00
—————————————————————————————————-
合計 3.9 MB/s | 75 MB 00:19
…
これでいいですか? [y/N]y
rpm_check_debug を実行しています
トランザクションのテストを実行しています
トランザクションのテストを成功しました
トランザクションを実行しています
インストールしています : mysql-community-common-5.6.26-2.el6.x86_64 1/7
インストールしています : mysql-community-libs-5.6.26-2.el6.x86_64 2/7
インストールしています : mysql-community-client-5.6.26-2.el6.x86_64 3/7
インストールしています : perl-DBI-1.609-4.el6.x86_64 4/7
インストールしています : mysql-community-server-5.6.26-2.el6.x86_64 5/7
インストールしています : mysql-community-libs-compat-5.6.26-2.el6.x86_64 6/7
削除中 : mysql-libs-5.1.73-5.el6_6.x86_64 7/7
Verifying : mysql-community-common-5.6.26-2.el6.x86_64 1/7
Verifying : perl-DBI-1.609-4.el6.x86_64 2/7
Verifying : mysql-community-libs-5.6.26-2.el6.x86_64 3/7
Verifying : mysql-community-server-5.6.26-2.el6.x86_64 4/7
Verifying : mysql-community-client-5.6.26-2.el6.x86_64 5/7
Verifying : mysql-community-libs-compat-5.6.26-2.el6.x86_64 6/7
Verifying : mysql-libs-5.1.73-5.el6_6.x86_64 7/7
インストール:
mysql-community-libs.x86_64 0:5.6.26-2.el6 mysql-community-libs-compat.x86_64 0:5.6.26-2.el6
mysql-community-server.x86_64 0:5.6.26-2.el6
依存性関連をインストールしました:
mysql-community-client.x86_64 0:5.6.26-2.el6 mysql-community-common.x86_64 0:5.6.26-2.el6
perl-DBI.x86_64 0:1.609-4.el6
置換:
mysql-libs.x86_64 0:5.1.73-5.el6_6
完了しました!
[/bash]
インストールしたMySQLのバージョンの確認
[bash]
$ mysqld –version
mysqld Ver 5.6.26 for Linux on x86_64 (MySQL Community Server (GPL))
[/bash]
自動起動の設定
インストール後は、自動起動がoffになっているので、自動起動するように設定する。
[bash]
$ chkconfig mysqld –list
mysqld 0:off 1:off 2:off 3:off 4:off 5:off 6:off
$ chkconfig mysqld on
$ chkconfig mysqld –list
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[/bash]
MySQLの起動
[bash]
$ service mysqld start
MySQL データベースを初期化中: 2015-08-10 14:06:31 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use –explicit_defaults_for_timestamp server option (see documentation for more details).
2015-08-10 14:06:31 0 [Note] /usr/sbin/mysqld (mysqld 5.6.26) starting as process 24192 …
2015-08-10 14:06:31 24192 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-08-10 14:06:31 24192 [Note] InnoDB: The InnoDB memory heap is disabled
a new database to be created!
…
[ OK ]
mysqld を起動中: [ OK ]
[/bash]
rootパスワードの変更
[bash]
$ /usr/bin/mysqladmin -u root password ‘new-password’
[/bash]
デフォルト文字コードの変更
デフォルトでは、文字コードが下記のようになっている。
[bash]
mysql> show variables like ‘character_set%’;
+————————–+—————————-+
| Variable_name | Value |
+————————–+—————————-+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+————————–+—————————-+
8 rows in set (0.01 sec)
[/bash]
そこで、/etc/my.cnf の設定に追記する。
[bash]
[mysqld]
character-set-server=utf8
[mysql]
default-character-set=utf8
[/bash]
MySQLサーバの再起動。
[bash]
$ service mysqld restart
[/bash]
デフォルト文字コードの設定の確認をする。
[bash]
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)
[/bash]
latin1 であった部分が utf8 に変更された。