5
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CentOS7(最新では無い)へMySQL(最新では無い)をインストールした覚書

Last updated at Posted at 2015-10-26

バージョンの確認

とある事情により、MySQL5.6 以上環境が必要になったので、MacOS/X El Captan 10.11.1 上の VMware Fusionで動作しているCentOS7 へインストールしました。

まずはバージョンの確認。

$ cat /etc/redhat-release
CentOS Linux release 7.1.1503 (Core)

最近はMariaDB化しているはずなので確認してみると、

$ yum list installed | grep maria
mariadb-libs.x86_64                    1:5.5.44-1.el7_1                @updates

やっぱり居たw ので、一応アンインストール。

$ sudo yum -y remove mariadb-libs
Loaded plugins: fastestmirror, langpacks
Resolving Dependencies
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.44-1.el7_1 will be erased
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
--> Running transaction check
---> Package postfix.x86_64 2:2.10.1-6.el7 will be erased
--> Finished Dependency Resolution
base/7/x86_64                                            | 3.6 kB     00:00     
extras/7/x86_64                                          | 3.4 kB     00:00     
extras/7/x86_64/primary_db                               |  99 kB     00:01     
updates/7/x86_64                                         | 3.4 kB     00:00     

Dependencies Resolved

================================================================================
 Package            Arch         Version                  Repository       Size
================================================================================
Removing:
 mariadb-libs       x86_64       1:5.5.44-1.el7_1         @updates        4.4 M
Removing for dependencies:
 postfix            x86_64       2:2.10.1-6.el7           @anaconda        12 M

Transaction Summary
================================================================================
Remove  1 Package (+1 Dependent package)

Installed size: 17 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : 2:postfix-2.10.1-6.el7.x86_64                                1/2 
  Erasing    : 1:mariadb-libs-5.5.44-1.el7_1.x86_64                         2/2 
  Verifying  : 1:mariadb-libs-5.5.44-1.el7_1.x86_64                         1/2 
  Verifying  : 2:postfix-2.10.1-6.el7.x86_64                                2/2 

Removed:
  mariadb-libs.x86_64 1:5.5.44-1.el7_1                                          

Dependency Removed:
  postfix.x86_64 2:2.10.1-6.el7                                                 

Complete!

細かくバージョン指定できるとはいえ、今回は新しければ良い!(つーか、5.5以前はダメよ)という感じだし、サクッとyumでインストール。

$ sudo yum -y install http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
Loaded plugins: fastestmirror, langpacks
mysql-community-release-el7-5.noarch.rpm                 | 6.0 kB     00:01     
Examining /var/tmp/yum-root-40KiJj/mysql-community-release-el7-5.noarch.rpm: mysql-community-release-el7-5.noarch
Marking /var/tmp/yum-root-40KiJj/mysql-community-release-el7-5.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-release.noarch 0:el7-5 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package               Arch   Version
                                Repository                             Size
================================================================================
Installing:
 mysql-community-release
                       noarch el7-5 /mysql-community-release-el7-5.noarch 4.3 k

Transaction Summary
================================================================================
Install  1 Package

Total size: 4.3 k
Installed size: 4.3 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : mysql-community-release-el7-5.noarch                         1/1 
  Verifying  : mysql-community-release-el7-5.noarch                         1/1 

Installed:
  mysql-community-release.noarch 0:el7-5                                        

Complete!

リポジトリファイルがインストールできたら、本体をインストール。

$ sudo yum -y install mysql
Loaded plugins: fastestmirror, langpacks
mysql-connectors-community                               | 2.5 kB     00:00     
mysql-tools-community                                    | 2.5 kB     00:00     
mysql56-community                                        | 2.5 kB     00:00     
(1/3): mysql-tools-community/x86_64/primary_db             |  22 kB   00:01     
(2/3): mysql-connectors-community/x86_64/primary_db        | 8.6 kB   00:01     
(3/3): mysql56-community/x86_64/primary_db                 | 109 kB   00:02     
Loading mirror speeds from cached hostfile
 * base: mirror.fairway.ne.jp
 * extras: centos.usonyx.net
 * updates: centos.usonyx.net
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.6.27-2.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) = 5.6.27-2.el7 for package: mysql-community-client-5.6.27-2.el7.x86_64
--> Running transaction check
---> Package mysql-community-libs.x86_64 0:5.6.27-2.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.6.27-2.el7 for package: mysql-community-libs-5.6.27-2.el7.x86_64
--> Running transaction check
---> Package mysql-community-common.x86_64 0:5.6.27-2.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package                   Arch      Version         Repository            Size
================================================================================
Installing:
 mysql-community-client    x86_64    5.6.27-2.el7    mysql56-community     19 M
Installing for dependencies:
 mysql-community-common    x86_64    5.6.27-2.el7    mysql56-community    256 k
 mysql-community-libs      x86_64    5.6.27-2.el7    mysql56-community    2.0 M

Transaction Summary
================================================================================
Install  1 Package (+2 Dependent packages)

Total download size: 21 M
Installed size: 99 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/mysql56-community/packages/mysql-community-common-5.6.27-2.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Public key for mysql-community-common-5.6.27-2.el7.x86_64.rpm is not installed
(1/3): mysql-community-common-5.6.27-2.el7.x86_64.rpm      | 256 kB   00:01     
(2/3): mysql-community-client-5.6.27-2.el7.x86_64.rpm      |  19 MB   00:06     
(3/3): mysql-community-libs-5.6.27-2.el7.x86_64.rpm        | 2.0 MB   00:07     
--------------------------------------------------------------------------------
Total                                              2.3 MB/s |  21 MB  00:09     
Retrieving key from file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:
 Userid     : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
 Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
 Package    : mysql-community-release-el7-5.noarch (@/mysql-community-release-el7-5.noarch)
 From       : file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : mysql-community-common-5.6.27-2.el7.x86_64                   1/3 
  Installing : mysql-community-libs-5.6.27-2.el7.x86_64                     2/3 
  Installing : mysql-community-client-5.6.27-2.el7.x86_64                   3/3 
  Verifying  : mysql-community-client-5.6.27-2.el7.x86_64                   1/3 
  Verifying  : mysql-community-common-5.6.27-2.el7.x86_64                   2/3 
  Verifying  : mysql-community-libs-5.6.27-2.el7.x86_64                     3/3 

Installed:
  mysql-community-client.x86_64 0:5.6.27-2.el7                                  

Dependency Installed:
  mysql-community-common.x86_64 0:5.6.27-2.el7                                  
  mysql-community-libs.x86_64 0:5.6.27-2.el7                                    

Complete!

続けて、残りのパッケージもインストールします(ログログ省略)。

$ sudo yum -y install mysql-devel
$ sudo yum -y install mysql-server
$ sudo yum -y install mysql-utilities

$ which mysql
/usr/bin/mysql
$ sudo service mysqld start
Redirecting to /bin/systemctl start  mysqld.service

さて、今はserviceではなくsystemctlでやる方法に変わっているので、起動登録を行います。

$ sudo systemctl list-unit-files | grep mysql
mysql.service                               enabled 
mysqld.service                              enabled

さてさて、最近は便利になりましたね―!なセットアップです。

$ sudo mysql_secure_installation

ログは省略します。

起動終了などなどのコマンドは以下の通りです。

$ sudo systemctl start mysqld.service
$ sudo systemctl stop mysqld.service
$ sudo systemctl restart mysqld.service

※追加
外部からのアクセスですが、my.cnfやiptables、mysqlでのgrantなどはググればいっぱい出てきます。
今回一番ハマったのは、firewall-cmdでした。

以下の通りに行えば、外部からのアクセスを通すようになります。

$ which firewall-cmd
/usr/bin/firewall-cmd
コマンドを確認

$ sudo firewall-cmd --get-service
RH-Satellite-6 amanda-client bacula bacula-client dhcp dhcpv6 dhcpv6-client dns ftp high-availability 	http https imaps ipp ipp-client ipsec kerberos kpasswd ldap ldaps libvirt libvirt-tls mdns mountd ms-wbt 	mysql nfs ntp openvpn pmcd pmproxy pmwebapi pmwebapis pop3s postgresql proxy-dhcp radius rpc-bind samba 	samba-client smtp ssh telnet tftp tftp-client transmission-client vnc-server wbem-https
今許可している設定はどうなってる?

$ sudo firewall-cmd --permanent --add-service=mysql
success
mysqlの通常設定も許可してね

$ sudo firewall-cmd --reload
success
再起動
5
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?