阿里云CentOS 7.1使用yum安装MySql5.6.24

  • 作者:vfhky | 时间:2015-06-25 09:43 | 分类:web

在前面两篇文章《2015博客升级记(四):CentOS 7.1编译安装MySQL5.7.7rc》《阿里云CentOS 7.1编译安装MySql5.6.24》中,都是采用编译MySQL源码的方式安装的,过程相对比较复杂。所以,这篇文章演示如何使用yum的方式安装MySql5.6.24。

1 常规错误的yum安装方法:

前文中记述了CentOS 6.5系统中通过yum方式快速地搭建了LNMP环境,那么是否也能在CentOS 7或CentOS 7.1系统中依葫芦画瓢安装MySql5.6.24呢?答案是否定的。

[root@typecodes ~]# yum -y install mysql mysql-server mysql-devel
.....................。
....省略部分安装过程....
.....................。 Installed:
mariadb.x86_64 1:5.5.41-2.el7_0 mariadb-devel.x86_64 1:5.5.41-2.el7_0 Dependency Installed:
keyutils-libs-devel.x86_64 0:1.5.8-3.el7 krb5-devel.x86_64 0:1.12.2-14.el7 libcom_err-devel.x86_64 0:1.42.9-7.el7 libselinux-devel.x86_64 0:2.2.2-6.el7
libsepol-devel.x86_64 0:2.1.9-3.el7 libverto-devel.x86_64 0:0.2.5-4.el7 openssl-devel.x86_64 1:1.0.1e-42.el7.4 pcre-devel.x86_64 0:8.32-14.el7
zlib-devel.x86_64 0:1.2.7-13.el7 Complete!

从上面的安装结果可以看出,没有安装mysql数据库,而是安装了mariadb数据!因为在CentOS 7和CentOS 7.1系统中,默认安装的mysql是它的分支mariadb。这里引用下百度百科关于mariadb的描述:

MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可 MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能轻松成为MySQL的代替品。

因此,下面这些正常的MySQL操作都是无效的:

#######无法把mysql服务加入系统启动
[root@typecodes ~]# chkconfig mysqld on
error reading information on service mysqld: No such file or directory
#######启动不了mysql
[root@typecodes ~]# service mysqld start
Redirecting to /bin/systemctl start mysqld.service
Failed to issue method call: Unit mysqld.service failed to load: No such file or directory.
#######没有安装mysql相关包
[root@typecodes ~]# rpm -qa |grep mysql
php-mysql-5.4.16-23.el7_0.3.x86_64
[root@typecodes ~]#
2 正确的安装方法:

众所周知,Linux系统自带的repo是不会自动更新每个软件的最新版本(基本都是比较靠后的稳定版),所以无法通过yum方式安装MySQL的高级版本。所以我们需要先安装带有当前可用的mysql5系列社区版资源的rpm包。

#######安装rpm包
[root@typecodes ~]# rpm -Uvh 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%]

这时查看当前可用的mysql安装资源:

[root@typecodes ~]# yum repolist enabled | grep "mysql.*-community.*"
mysql-connectors-community/x86_64 MySQL Connectors Community 14
mysql-tools-community/x86_64 MySQL Tools Community 17
mysql56-community/x86_64 MySQL 5.6 Community Server 139

从上面的列表可以看出,mysql56-community/x86_64MySQL 5.6 Community Server可以使用。

因此,我们就可以直接用yum方式安装了MySQL5.6版本了。

[root@typecodes ~]# yum -y install mysql-community-server
Loaded plugins: axelget, langpacks
No metadata available for base
No metadata available for epel
No metadata available for extras
(Failed to load module fastestmirror: No module named fastestmirror)
repomd.xml | 2.5 kB 00:00:00
update mysql-connectors-community metadata successfully
(Failed to load module fastestmirror: No module named fastestmirror)
repomd.xml | 2.5 kB 00:00:00
update mysql-tools-community metadata successfully
(Failed to load module fastestmirror: No module named fastestmirror)
repomd.xml | 2.5 kB 00:00:00
update mysql56-community metadata successfully
No metadata available for updates
mysql-connectors-community | 2.5 kB 00:00:00
mysql-tools-community | 2.5 kB 00:00:00
mysql56-community | 2.5 kB 00:00:00
(1/3): mysql-connectors-community/x86_64/primary_db | 7.3 kB 00:00:00
(2/3): mysql56-community/x86_64/primary_db | 83 kB 00:00:01
mysql-tools-community/x86_64/p FAILED ============================================== ] 19 kB/s | 92 kB 00:00:00 ETA
http://repo.mysql.com/yum/mysql-tools-community/el/7/x86_64/repodata/3301d2eb425f300dec5a46c4201d08f2cf9232a6-primary.sqlite.bz2: [Errno 12] Timeout on http://repo.mysql.com/yum/mysql-tools-community/el/7/x86_64/repodata/3301d2eb425f300dec5a46c4201d08f2cf9232a6-primary.sqlite.bz2: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 3 seconds')
Trying other mirror.
(3/3): mysql-tools-community/x86_64/primary_db | 15 kB 00:00:00
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.6.24-3.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.6.24-3.el7 for package: mysql-community-server-5.6.24-3.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) = 5.6.24-3.el7 for package: mysql-community-server-5.6.24-3.el7.x86_64
--> Processing Dependency: perl(DBI) for package: mysql-community-server-5.6.24-3.el7.x86_64
--> Running transaction check
---> Package mariadb.x86_64 1:5.5.41-2.el7_0 will be obsoleted
---> Package mysql-community-client.x86_64 0:5.6.24-3.el7 will be obsoleting
--> Processing Dependency: mysql-community-libs(x86-64) = 5.6.24-3.el7 for package: mysql-community-client-5.6.24-3.el7.x86_64
---> Package mysql-community-common.x86_64 0:5.6.24-3.el7 will be installed
---> Package perl-DBI.x86_64 0:1.627-4.el7 will be installed
--> Processing Dependency: perl(RPC::PlServer) >= 0.2001 for package: perl-DBI-1.627-4.el7.x86_64
--> Processing Dependency: perl(RPC::PlClient) >= 0.2000 for package: perl-DBI-1.627-4.el7.x86_64
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.41-2.el7_0 will be obsoleted
--> Processing Dependency: mariadb-libs(x86-64) = 1:5.5.41-2.el7_0 for package: 1:mariadb-devel-5.5.41-2.el7_0.x86_64
---> Package mysql-community-libs.x86_64 0:5.6.24-3.el7 will be obsoleting
---> Package perl-PlRPC.noarch 0:0.2020-14.el7 will be installed
--> Processing Dependency: perl(Net::Daemon) >= 0.13 for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Net::Daemon::Test) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Net::Daemon::Log) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Compress::Zlib) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Running transaction check
---> Package mariadb-devel.x86_64 1:5.5.41-2.el7_0 will be obsoleted
---> Package mysql-community-devel.x86_64 0:5.6.24-3.el7 will be obsoleting
---> Package perl-IO-Compress.noarch 0:2.061-2.el7 will be installed
--> Processing Dependency: perl(Compress::Raw::Zlib) >= 2.061 for package: perl-IO-Compress-2.061-2.el7.noarch
--> Processing Dependency: perl(Compress::Raw::Bzip2) >= 2.061 for package: perl-IO-Compress-2.061-2.el7.noarch
---> Package perl-Net-Daemon.noarch 0:0.48-5.el7 will be installed
--> Running transaction check
---> Package perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 will be installed
---> Package perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 will be installed
--> Finished Dependency Resolution Dependencies Resolved =======================================================================================================================================================================
Package Arch Version Repository Size
=======================================================================================================================================================================
Installing:
mysql-community-client x86_64 5.6.24-3.el7 mysql56-community 19 M
replacing mariadb.x86_64 1:5.5.41-2.el7_0
mysql-community-devel x86_64 5.6.24-3.el7 mysql56-community 3.4 M
replacing mariadb-devel.x86_64 1:5.5.41-2.el7_0
mysql-community-libs x86_64 5.6.24-3.el7 mysql56-community 2.0 M
replacing mariadb-libs.x86_64 1:5.5.41-2.el7_0
mysql-community-server x86_64 5.6.24-3.el7 mysql56-community 58 M
Installing for dependencies:
mysql-community-common x86_64 5.6.24-3.el7 mysql56-community 256 k
perl-Compress-Raw-Bzip2 x86_64 2.061-3.el7 base 32 k
perl-Compress-Raw-Zlib x86_64 1:2.061-4.el7 base 57 k
perl-DBI x86_64 1.627-4.el7 base 802 k
perl-IO-Compress noarch 2.061-2.el7 base 260 k
perl-Net-Daemon noarch 0.48-5.el7 base 51 k
perl-PlRPC noarch 0.2020-14.el7 base 36 k Transaction Summary
=======================================================================================================================================================================
Install 4 Packages (+7 Dependent packages) Total download size: 83 M
Downloading packages:
mysql-community-devel-5.6.24-3.el7.x86_64.rpm | 3.4 MB 00:00:03
mysql-community-client-5.6.24-3.el7.x86_64.rpm | 19 MB 00:00:05
mysql-community-server-5.6.24-3.el7.x86_64.rpm | 58 MB 00:00:11
mysql-community-libs-5.6.24-3.el7.x86_64.rpm | 2.0 MB 00:00:02
perl-DBI-1.627-4.el7.x86_64.rpm | 0 B 00:00:01 ...
perl-DBI-1.627-4.el7.x86_64.rpm | 802 kB 00:00:00
(1/6): perl-Compress-Raw-Zlib-2.061-4.el7.x86_64.rpm | 57 kB 00:00:00
(2/6): perl-Net-Daemon-0.48-5.el7.noarch.rpm | 51 kB 00:00:00
(3/6): perl-PlRPC-0.2020-14.el7.noarch.rpm | 36 kB 00:00:00
(4/6): perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64.rpm | 32 kB 00:00:00
(5/6): perl-IO-Compress-2.061-2.el7.noarch.rpm | 260 kB 00:00:00
warning: /var/cache/yum/x86_64/7/mysql56-community/packages/mysql-community-common-5.6.24-3.el7.x86_64.rpm: V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY 00:00:01 ETA
Public key for mysql-community-common-5.6.24-3.el7.x86_64.rpm is not installed
(6/6): mysql-community-common-5.6.24-3.el7.x86_64.rpm | 256 kB 00:00:01
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 388 kB/s | 692 kB 00:00:01
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 (installed)
From : file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
Installing : mysql-community-common-5.6.24-3.el7.x86_64 1/14
Installing : mysql-community-libs-5.6.24-3.el7.x86_64 2/14
Installing : mysql-community-client-5.6.24-3.el7.x86_64 3/14
Installing : perl-Net-Daemon-0.48-5.el7.noarch 4/14
Installing : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64 5/14
Installing : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64 6/14
Installing : perl-IO-Compress-2.061-2.el7.noarch 7/14
Installing : perl-PlRPC-0.2020-14.el7.noarch 8/14
Installing : perl-DBI-1.627-4.el7.x86_64 9/14
Installing : mysql-community-server-5.6.24-3.el7.x86_64 10/14
Installing : mysql-community-devel-5.6.24-3.el7.x86_64 11/14
Erasing : 1:mariadb-devel-5.5.41-2.el7_0.x86_64 12/14
Erasing : 1:mariadb-5.5.41-2.el7_0.x86_64 13/14
Erasing : 1:mariadb-libs-5.5.41-2.el7_0.x86_64 14/14
Verifying : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64 1/14
Verifying : mysql-community-common-5.6.24-3.el7.x86_64 2/14
Verifying : mysql-community-devel-5.6.24-3.el7.x86_64 3/14
Verifying : mysql-community-client-5.6.24-3.el7.x86_64 4/14
Verifying : perl-PlRPC-0.2020-14.el7.noarch 5/14
Verifying : mysql-community-server-5.6.24-3.el7.x86_64 6/14
Verifying : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64 7/14
Verifying : mysql-community-libs-5.6.24-3.el7.x86_64 8/14
Verifying : perl-Net-Daemon-0.48-5.el7.noarch 9/14
Verifying : perl-DBI-1.627-4.el7.x86_64 10/14
Verifying : perl-IO-Compress-2.061-2.el7.noarch 11/14
Verifying : 1:mariadb-5.5.41-2.el7_0.x86_64 12/14
Verifying : 1:mariadb-devel-5.5.41-2.el7_0.x86_64 13/14
Verifying : 1:mariadb-libs-5.5.41-2.el7_0.x86_64 14/14 Installed:
mysql-community-client.x86_64 0:5.6.24-3.el7 mysql-community-devel.x86_64 0:5.6.24-3.el7 mysql-community-libs.x86_64 0:5.6.24-3.el7
mysql-community-server.x86_64 0:5.6.24-3.el7 Dependency Installed:
mysql-community-common.x86_64 0:5.6.24-3.el7 perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 perl-DBI.x86_64 0:1.627-4.el7
perl-IO-Compress.noarch 0:2.061-2.el7 perl-Net-Daemon.noarch 0:0.48-5.el7 perl-PlRPC.noarch 0:0.2020-14.el7 Replaced:
mariadb.x86_64 1:5.5.41-2.el7_0 mariadb-devel.x86_64 1:5.5.41-2.el7_0 mariadb-libs.x86_64 1:5.5.41-2.el7_0 Complete!
3 MySQL安装完成后,进行相关配置

安装完MySQL后,需要进行一些基础配置工作:

#######安装成功后,将其加入开机启动
[root@typecodes ~]# systemctl enable mysqld #######启动mysql服务进程
[root@typecodes ~]# systemctl start mysqld #######配置mysql(设置密码等)
[root@typecodes ~]# mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here. 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] y [设置root用户密码]
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success! 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] y [禁止root远程登录]
... Success! 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] y [删除test数据库]
- Dropping test database...
ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist
... Failed! Not critical, keep moving...
- Removing privileges on test database...
... Success! Reloading the privilege tables will ensure that all changes made so far
will take effect immediately. Reload privilege tables now? [Y/n] y [刷新权限]
... Success! All done! If you've completed all of the above steps, your MySQL
installation should now be secure. Thanks for using MySQL! Cleaning up...
4 其它说明

至于其它诸如使用root用户创建其它mysql用户或者导入sql文件到数据库中的操作,这里就不说了,可以参考前面的两篇文章。

[转]阿里云CentOS 7.1使用yum安装MySql5.6.24的更多相关文章

  1. 阿里云CentOS 7.1使用yum安装MySql5.6.24

    正确的安装方法: 众所周知,Linux系统自带的repo是不会自动更新每个软件的最新版本(基本都是比较靠后的稳定版),所以无法通过yum方式安装MySQL的高级版本.所以我们需要先安装带有当前可用的m ...

  2. 转:在CentOS 7.3使用yum安装 MySql5.6.24

    按照CentOS 6.5的方法在CentOS 7上安装会失败,需要按照下文进行安装. 1.安装rpm包 Linux系统自带的repo是不会自动更新每个软件的最新版本(基本都是比较靠后的稳定版),所以无 ...

  3. CentOS 7.1使用yum安装MySql5.6.24

    http://www.cnblogs.com/yuanfeiblog/p/5276492.html

  4. 阿里云centos postgresql9.4源码安装 精简步骤、问题解答

    阿里云centos环境源码安装postgresql9.4 本文的安装步骤主要来源于http://www.cnblogs.com/mchina/archive/2012/06/06/2539003.ht ...

  5. 阿里云Centos 7 FTP(vsftp)服务安装及配置

    #检查vsftpd是否安装 rpm -qa | grep vsftpd #检查vsftpd版本并安装 yum list vsftpd yum install vsftpd #设置开机启动 system ...

  6. 阿里云ECS下基于Centos7.4安装MySQL5.7.20

     1.首先登录阿里云ECS服务器,如下图所示: 2.卸载MariaDB 说明:CentOS7.x默认安装MariaDB而不是MySQL,而且yum服务器上也移除了MySQL相关的软件包.因为Maria ...

  7. CentOS 7 下使用yum安装MySQL5.7.20 最简单图文详解

    CentOS7默认数据库是mariadb, 但是 好多用的都是mysql ,但是CentOS7的yum源中默认好像是没有mysql的. 上一篇安装的是5.6的但是我想安装5.7的  yum安装是最简单 ...

  8. CentOS 7 下使用yum安装MySQL5.7.20

    CentOS7默认数据库是mariadb, 但是 好多用的都是mysql ,但是CentOS7的yum源中默认好像是没有mysql的. 上一篇安装的是5.6的但是我想安装5.7的  yum安装是最简单 ...

  9. CentOS 6.5通过yum安装 MySQL-5.5

    1.安装mysql-5.5的yum源 rpm -ivh http://repo.mysql.com/yum/mysql-5.5-community/el/6/x86_64/mysql-communit ...

随机推荐

  1. wx小程序 使用字体

    1.下载项目下的字体库 2.解压复制iconfont.css中的代码到,小程序 app.wxss 3.使用: //icon-begindate表示开始时间的图标 <text class=&quo ...

  2. Gauss error function

    0. error function erf(x)=1π∫−xxe−t2dt" role="presentation">erf(x)=1π−−√∫x−xe−t2dte ...

  3. php防止sql注入的方法(转)

    [一.在服务器端配置] 安全,PHP代码编写是一方面,PHP的配置更是非常关键. 我们php手手工安装的,php的默认配置文件在 /usr/local/apache2/conf/php.ini,我们最 ...

  4. vue查缺补漏题

    一.对于MVVM的理解? MVVM 是 Model-View-ViewModel 的缩写.Model代表数据模型,也可以在Model中定义数据修改和操作的业务逻辑.View 代表UI 组件,它负责将数 ...

  5. 03 事务,连接池DBCP,C3P0,DBUtils

    事务 Transaction  其实指的一组操作,里面包含许多个单一的逻辑.只要有一个逻辑没有执行成功,那么都算失败. 所有的数据都回归到最初的状态(回滚) 事务的作用:为了确保逻辑的成功. 例子: ...

  6. Python学习之---Python中的内置函数(方法)(更新中。。。)

    add(item)   #将item添加到s中,如果item已经在s中,则无任何效果 break        #退出循环,不会再运行循环中余下的代码 bool()     #将参数转换为布尔型 by ...

  7. 写出一个程序,接受一个由字母和数字组成的字符串,和一个字符,然后输出输入字符串中含有该字符的个数。不区分大小写。java算法

    知识点一:equalsIgnore 1.使用equals( )方法比较两个字符串是否相等.它具有如下的一般形式: boolean equals(Object str) 这里str是一个用来与调用字符串 ...

  8. java 8大数据类型

    第一类:逻辑型boolean 第二类:文本型char 1.JAVA中,char占2字节,16位.可在存放汉字 2.char赋值 char a='a';  //任意单个字符,加单引号. char a=' ...

  9. servlet路径映射中的完全路径匹配、目录匹配、扩展名匹配

    在servlet路径映射中,关于url-pattern的配置有三种,分别是完全路径匹配.目录匹配.扩展名匹配 其优先级分别为:完全路径匹配>目录匹配>扩展名匹配: 一.三种路径印射的区别 ...

  10. JS从数组中随机取出几个数组元素的方法

    原文链接:http://caibaojian.com/js-get-random-elements-from-array.html js如何从一个数组中随机取出一个元素或者几个元素. 假如数组为· v ...