+135 410 16684Mon. - Fri. 10:00-22:00

Amazon CentOS7 AMI安装MySQL5.6教程

Amazon CentOS7 AMI安装MySQL5.6教程

Amazon CentOS7 AMI安装MySQL5.6教程

有客户需要让这次在Amazon CentOS7 AMI安装MySQL5.6.22。

centos用户登录到Amazon EC2服务器以后,sudo到root用户。

在CentOS7 AMI执行yum install mysql-server命令会发现无法安装mysql server。

# sudo su -
# yum install mysql-server
Loaded plugins: fastestmirror
base                                                     | 3.6 kB     00:00
epel/x86_64/metalink                                     | 5.5 kB     00:00
epel                                                     | 4.4 kB     00:00
extras                                                   | 3.4 kB     00:00
rpmforge                                                 | 1.9 kB     00:00
updates                                                  | 3.4 kB     00:00
epel/x86_64/primary_db                                     | 3.8 MB   00:00
(1/2): epel/x86_64/updateinfo                              | 230 kB   00:00
(2/2): epel/x86_64/pkgtags                                 | 1.3 MB   00:00
Loading mirror speeds from cached hostfile
 * base: www.ftp.ne.jp
 * epel: s3-mirror-ap-northeast-1.fedoraproject.org
 * extras: www.ftp.ne.jp
 * rpmforge: ftp.riken.jp
 * updates: www.ftp.ne.jp
No package mysql-server available.
Error: Nothing to do

因为,CentOS7的默认数据库是MariaDB。

 

1, 配置MySQL5.6的Repository

访问http://www.mysql.com/downloads/以后,点击「Downloads」→「Yum Repository」。

mysql.org_

选择Red Hat Enterprise Linux 7 / Oracle Linux 7 (Architecture Independent), RPM Package的「Download」

Download

在这里会显示登录Oracle的页面,但是不必登录,拷贝No thanks, just start my download.的链接就可以。

拷贝的链接是:http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

MySQL5.6-Repository

配置MySQL5.6的yum源。

# rpm -ivh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
Retrieving http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-release-el7-5    ################################# [100%]

确认MySQL5.6yum源存在。

# yum repolist
Loaded plugins: fastestmirror
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-connectors-community/x86_64/primary_db        | 7.0 kB   00:00
(2/3): mysql-tools-community/x86_64/primary_db             |  11 kB   00:00
(3/3): mysql56-community/x86_64/primary_db                 |  59 kB   00:00
Loading mirror speeds from cached hostfile
 * base: www.ftp.ne.jp
 * epel: ftp.jaist.ac.jp
 * extras: www.ftp.ne.jp
 * rpmforge: ftp.riken.jp
 * updates: www.ftp.ne.jp
repo id                           repo name                               status
base/7/x86_64                     CentOS-7 - Base                         8,465
epel/x86_64                       Extra Packages for Enterprise Linux 7 - 6,912
extras/7/x86_64                   CentOS-7 - Extras                         102
mysql-connectors-community/x86_64 MySQL Connectors Community                 12
mysql-tools-community/x86_64      MySQL Tools Community                      12
mysql56-community/x86_64          MySQL 5.6 Community Server                 94
rpmforge                          RHEL 7 - RPMforge.net - dag               245
updates/7/x86_64                  CentOS-7 - Updates                      1,497
repolist: 17,339

2, 安装MySQL

# yum install mysql-server

# mysql --version
mysql  Ver 14.14 Distrib 5.6.22, for Linux (x86_64) using  EditLine wrapper

成功的在Amazon CentOS7 AMI上安装了MySQL5.6.22。

小结

CentOS7,好像有不少改变呀。好像service命令变为systemctl命令了。

# service mysqld stop
Redirecting to /bin/systemctl stop  mysqld.service