在Centos7中用MariaDB代替了mysql数据库。所以在新安装MySQL前必须做好对系统的清理工作。

一.清理CentOS7下的MariaDB。

[root@localhost ~]#rpm -qa | gremp mariadb

        [root@localhost ~]# rpm -e --nodeps mariadb.x86_64 1:5.5.41-2.el7_0

二.下载MySQL的yum包

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

[root@localhost ~]#wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

[root@localhost ~]# rpm -ivh mysql-community-release-el7-5.noarch.rpm

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

       [root@localhost ~]# yum repolist enabled | grep "mysql.*-community.*"
mysql-connectors-community/x86_64  MySQL Connectors Community   21
mysql-tools-community/x86_64       MySQL Tools Community        33
mysql56-community/x86_64           MySQL 5.6 Community Server  214

安装mysql

[root@localhost ~]#yum install mysql-community-server

已加载插件:fastestmirror, langpacks

base                                      | 3.6 kB     00:00

extras                                    | 3.4 kB     00:00

mysql-connectors-community                | 2.5 kB     00:00

mysql-tools-community                     | 2.5 kB     00:00

mysql56-community                         | 2.5 kB     00:00

updates                                   | 3.4 kB     00:00

(1/5): extras/7/x86_64/primary_db         | 117 kB   00:00

(2/5): mysql-connectors-community/x86_64/primary_db | 9.8 kB   00:00

(3/5): mysql-tools-community/x86_64/primary_db   |  25 kB   00:01

(4/5): mysql56-community/x86_64/primary_db       | 115 kB   00:01

(5/5): updates/7/x86_64/primary_db               | 3.9 MB   00:01

Determining fastest mirrors

* base: mirrors.pubyun.com

* extras: mirrors.pubyun.com

* updates: mirrors.pubyun.com

正在解决依赖关系

--> 正在检查事务

---> 软件包 mysql-community-server.x86_64.0.5.6.29-2.el7 将被 安装

--> 正在处理依赖关系 mysql-community-common(x86-64) = 5.6.29-2.el7,它被软件包 mysql-community-server-5.6.29-2.el7.x86_64 需要

--> 正在处理依赖关系 mysql-community-client(x86-64) = 5.6.29-2.el7,它被软件包 mysql-community-server-5.6.29-2.el7.x86_64 需要

--> 正在检查事务

---> 软件包 mysql-community-client.x86_64.0.5.6.29-2.el7 将被 安装

--> 正在处理依赖关系 mysql-community-libs(x86-64) = 5.6.29-2.el7,它被软件包 mysql-community-client-5.6.29-2.el7.x86_64 需要

---> 软件包 mysql-community-common.x86_64.0.5.6.29-2.el7 将被 安装

--> 正在检查事务

---> 软件包 mysql-community-libs.x86_64.0.5.6.29-2.el7 将被 安装

--> 解决依赖关系完成

依赖关系解决

=================================================================

Package        架构      版本           源                  大小

=================================================================

正在安装:

mysql-community-server    x86_64    5.6.29-2.el7    mysql56-community     58 M

为依赖而安装:

mysql-community-client    x86_64    5.6.29-2.el7    mysql56-community     19 M

mysql-community-common    x86_64    5.6.29-2.el7    mysql56-community    256 k

mysql-community-libs      x86_64    5.6.29-2.el7    mysql56-community    2.0 M

事务概要

=================================================================

安装  1 软件包 (+3 依赖软件包)

总下载量:79 M

安装大小:344 M

Is this ok [y/d/N]: y

Downloading packages:

警告:/var/cache/yum/x86_64/7/mysql56-community/packages/mysql-community-common-5.6.29-2.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY

mysql-community-common-5.6.29-2.el7.x86_64.rpm 的公钥尚未安装

(1/4): mysql-community-common-5.6.29-2.el7.x86_64.rpm      | 256 kB   00:01

(2/4): mysql-community-libs-5.6.29-2.el7.x86_64.rpm        | 2.0 MB   00:02

(3/4): mysql-community-server-5.6.29-2.el7.x86_64.rpm      |  58 MB   00:29

mysql-community-client-5.6.29- FAILED

http://repo.mysql.com/yum/mysql-5.6-community/el/7/x86_64/mysql-community-client-5.6.29-2.el7.x86_64.rpm: [Errno 12] Timeout on http://repo.mysql.com/yum/mysql-5.6-community/el/7/x86_64/mysql-community-client-5.6.29-2.el7.x86_64.rpm: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')

正在尝试其它镜像。

(4/4): mysql-community-client-5.6.29-2.el7.x86_64.rpm      |  19 MB   12:12

-----------------------------------------------------------------

总计                                    105 kB/s |  79 MB  12:51

从 file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql 检索密钥

导入 GPG key 0x5072E1F5:

用户ID     : "MySQL Release Engineering <mysql-build@oss.oracle.com>"

指纹       : a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5

软件包     : mysql-community-release-el7-5.noarch (installed)

来自       : file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

是否继续?[y/N]:y

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

警告:RPM 数据库已被非 yum 程序修改。

正在安装    : mysql-community-common-5.6.29-2.el7.x86_64                  1/4

正在安装    : mysql-community-libs-5.6.29-2.el7.x86_64                    2/4

正在安装    : mysql-community-client-5.6.29-2.el7.x86_64                  3/4

正在安装    : mysql-community-server-5.6.29-2.el7.x86_64                  4/4

warning: /etc/my.cnf created as /etc/my.cnf.rpmnew

验证中      : mysql-community-common-5.6.29-2.el7.x86_64                  1/4

验证中      : mysql-community-libs-5.6.29-2.el7.x86_64                    2/4

验证中      : mysql-community-client-5.6.29-2.el7.x86_64                  3/4

验证中      : mysql-community-server-5.6.29-2.el7.x86_64                  4/4

已安装:

mysql-community-server.x86_64 0:5.6.29-2.el7

作为依赖被安装:

mysql-community-client.x86_64 0:5.6.29-2.el7

mysql-community-common.x86_64 0:5.6.29-2.el7

mysql-community-libs.x86_64 0:5.6.29-2.el7

完毕!

三.MySQL安装完成后,进行相关配置

a)   #######安装成功后,将其加入开机启动
systemctl enable mysqld
b) #######启动mysql服务进程
        systemctl start mysqld
        c) #######配置mysql(设置密码等)
        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...

四.Yum安装后mysql的文件所在的位置:

/usr/bin(客户端程序和脚本)

/usr/sbin(mysql服务器)

/var/lib/mysql/(日志文件和数据库)

/usr/share/doc/packages(文档)

/usr/include/mysql(包含(头)文件)

/usr/lib/mysql(库文件)

/usr/share/mysql/(错误消息和字符集文件)

/usr/share/sql-bench(基准程序)

五.Yum安装的优缺点

优点:安装简单,适合初学者学习使用

缺点:需要单独下载客户端和服务器;安装路径不灵活,默认路径不能修改,一台服务器只能安装一个MySQL

CentOS7下yum方式安装mysql5.6的更多相关文章

  1. centos7下yum方式安装MySQL5.7

    前言: MySQL作为一款免费.开源数据库产品,已经问世就饱受关注,很多中小企业甚至是大企业都钟爱MySQL,随着大数据的不断发展,我们接触的信息量也越来越多,虽然NoSQL是大数据的宠儿,但MySQ ...

  2. CentOS7环境下yum方式安装MySQL5.7

    这篇博文主要是从网上摘抄的,做个记录,以后如果有同样的需求,可以直接翻自己的记录.感谢两位大神: https://www.cnblogs.com/luohanguo/p/9045391.html ht ...

  3. CentOS7系统yum方式安装MySQL5.7

    参考:https://www.cnblogs.com/bigbrotherer/p/7241845.html#top 1.在CentOS中默认安装有MariaDB,这个是MySQL的分支,但为了需要, ...

  4. centos7使用yum方式安装MySQL5.7

    yum -y localinstall http://mirrors.ustc.edu.cn/mysql-repo/mysql57-community-release-el7.rpm yum inst ...

  5. CentOS 6 下RPM方式安装MySQL5.6

    CentOS 6 下RPM方式安装MySQL5.6 1. 下载Linux对应的RPM包,如:CentOS6.7_64对应的RPM包,如下:[root@mysql ~]# ll总用量 113808-rw ...

  6. centos7使用yum方式安装node_exporter

    官网下载地址:https://prometheus.io/download/ 选择对应的系统版本 官网提供的是压缩包,点击旁边的github地址 github页面显示的有yum安装和docker安装, ...

  7. centos7.x下环境搭建(一)--yum方式安装mysql5.7

    前两天因为数据库被黑客攻击,导致数据被删除,数据库被损坏,系统重新安装了一下,所以环境也需要重新再搭一遍,包括mysql.nodejs.git.nginx和redis的安装.由于之前安装的mysql安 ...

  8. Windows 下noinstall方式安装 mysql-5.7.5-m15-winx64

    下载解压不说 我解压在:E:\DBFiles\mysql-5.7.15-winx64\mysql-5.7.15-winx64 添加配置文件E:\DBFiles\mysql-5.7.15-winx64\ ...

  9. 使用yum方式安装mysql5.6

    1.新开的云服务器,需要检测系统是否自带安装mysql # yum list installed | grep mysql 2.如果发现有系统自带mysql,果断这么干 # yum -y remove ...

随机推荐

  1. zend 和 esftp插件开发大型PHP项目,ZEND最常用快捷键

    先说一下如何安装zend的esftp插件,下载插件esftp-1.1.1.zip,下载地址http://sourceforge.net/projects/esftp/ 或者 http://yun.ba ...

  2. IOS int NSInteger NSNumber区分

    1.NSNumber 是一个类继承于NSValue 即一个基本数据类型的集合 包括char a signed or unsigned char, short int, int, long int, l ...

  3. Python map,reduce,filter,apply

    map(function, iterable, ...) map()函数接收两个参数,一个是函数,一个是可迭代的对象,map将传入的函数依次作用到序列的每个元素,并把结果作为新的list返回. 基本等 ...

  4. 斯坦福机器学习视频笔记 Week2 多元线性回归 Linear Regression with Multiple Variables

    相比于week1中讨论的单变量的线性回归,多元线性回归更具有一般性,应用范围也更大,更贴近实际. Multiple Features 上面就是接上次的例子,将房价预测问题进行扩充,添加多个特征(fea ...

  5. tp导出excel

    //数据导出 protected function dao($db,$where,$join,$field){ $data = M($db)->join($join)->where($wh ...

  6. 算法(Algorithms)第4版 练习 1.5.14

    package com.qiusongde; import edu.princeton.cs.algs4.StdIn; import edu.princeton.cs.algs4.StdOut; pu ...

  7. 【转】Struts2的线程安全 和Struts2中的设计模式----ThreadLocal模式

    [转]Struts2的线程安全 和Struts2中的设计模式----ThreadLocal模式 博客分类: 企业应用面临的问题 java并发编程 Struts2的线程安全ThreadLocal模式St ...

  8. R基础之批处理--R IN ACTION

    1.5 批处理多数情况下,我们都会交互式地使用R:在提示符后输入命令,接着等待该命令的输出结果.偶尔,我们可能想要以一种重复的.标准化的.无人值守的方式执行某个R程序,例如,你可能需要每个月生成一次相 ...

  9. KbmMW-及相关

    KbmMW框架是收费的,不在此提供下载,如需购买,请自行联系作者Kim Madsen. 网址资源: 官网主页:http://www.components4programmers.com/product ...

  10. 6 Python 数据类型—字符串

    字符串是 Python 中最常用的数据类型.我们可以使用引号('或")来创建字符串. 创建字符串很简单,只要为变量分配一个值即可. var1 = 'Hello World!' var2 = ...