# cat /etc/redhat-release CentOS release 6.7 (Final) # uname -a Linux my01 2.6.32-573.el6.x86_64 #1 SMP Thu Jul 23 15:44:03 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
updatesリポジトリからVer5.1がインストール可能
# yum install mysql-server mysql-client mysql-devel ~省略~ ========================================================================================== パッケージ アーキテクチャ バージョン リポジトリー 容量 ========================================================================================== インストールしています: mysql-devel x86_64 5.1.73-5.el6_7.1 updates 129 k mysql-server x86_64 5.1.73-5.el6_7.1 updates 8.6 M ~省略~
PHPとの親和を考えてremiリポジトリからインストール、と思うとVer5.5がインストール可能
# rpm -Uvh http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm # rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm # rpm -Uvh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm # yum --enablerepo=remi,remi-php56,remi-php70 install mysql-server mysql-client mysql-devel ~省略~ ========================================================================================== パッケージ アーキテクチャ バージョン リポジトリー 容量 ========================================================================================== インストールしています: mysql x86_64 5.5.48-1.el6.remi remi 5.8 M mysql-devel x86_64 5.5.48-1.el6.remi remi 164 k mysql-server x86_64 5.5.48-1.el6.remi remi 10 M ~省略~
公式リポジトリからは、標準でVer5.7が、任意でVer5.6がインストール可能
# yum install http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm # less /etc/yum.repos.d/mysql-community.repo [mysql-connectors-community] name=MySQL Connectors Community baseurl=http://repo.mysql.com/yum/mysql-connectors-community/el/6/$basearch/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql [mysql-tools-community] name=MySQL Tools Community baseurl=http://repo.mysql.com/yum/mysql-tools-community/el/6/$basearch/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql # Enable to use MySQL 5.5 [mysql55-community] name=MySQL 5.5 Community Server baseurl=http://repo.mysql.com/yum/mysql-5.5-community/el/6/$basearch/ enabled=0 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql # Enable to use MySQL 5.6 [mysql56-community] name=MySQL 5.6 Community Server baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/ enabled=0 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql [mysql57-community] name=MySQL 5.7 Community Server baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql # yum install mysql-community-server mysql-community-devel ~省略~ ========================================================================================== パッケージ アーキテクチャ バージョン リポジトリー 容量 ========================================================================================== インストールしています: mysql-community-devel x86_64 5.7.11-1.el6 mysql57-community 3.7 M mysql-community-libs x86_64 5.7.11-1.el6 mysql57-community 2.1 M 置き換えています mysql-libs.x86_64 5.1.73-5.el6_7.1 mysql-community-server x86_64 5.7.11-1.el6 mysql57-community 135 M ~省略~ # yum --enablerepo=mysql56-community --disablerepo=mysql57-community install mysql-community-server mysql-community-devel ~省略~ ========================================================================================== パッケージ アーキテクチャ バージョン リポジトリー 容量 ========================================================================================== インストールしています: mysql-community-devel x86_64 5.6.29-2.el6 mysql56-community 3.2 M mysql-community-libs x86_64 5.6.29-2.el6 mysql56-community 1.9 M 置き換えています mysql-libs.x86_64 5.1.73-5.el6_7.1 mysql-community-server x86_64 5.6.29-2.el6 mysql56-community 53 M ~省略~
# yum --enablerepo=remi install mysql-server mysql-client mysql-devel
文字コードの設定
# vi /etc/my.cnf
以下の行を先頭に追加
[mysqld] character_set_server=utf8 skip_character_set_client_handshake
起動
# /etc/rc.d/init.d/mysqld start
自動起動設定
# chkconfig mysqld on
Set root password? [Y/n]
UPDATE mysql.user SET Password=PASSWORD('$esc_pass') WHERE User='root';
Remove anonymous users? [Y/n]
DELETE FROM mysql.user WHERE User='';
Disallow root login remotely? [Y/n]
DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');
Remove test database and access to it? [Y/n]
DROP DATABASE test;
DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%'
Reload privilege tables now? [Y/n]
FLUSH PRIVILEGES;
使用するアプリケーション・環境に応じてユーザ、DBを追加する。
# mysql -u root -p
e.g.1)
mysql> GRANT ALL ON redmine.* TO 'redmine'@'localhost' IDENTIFIED BY 'redmine'; mysql> CREATE DATABASE redmine;
e.g.2)
mysql> GRANT USAGE ON *.* TO 'openpne'@'localhost' IDENTIFIED BY 'pwd'; mysql> GRANT ALL ON openpne3.* TO 'openpne'@'localhost';
mysql> exit