CentOS7下yum方式安装mysql5.6
2016-04-07 13:04
826 查看
在Centos7中用MariaDB代替了mysql数据库。所以在新安装MySQL前必须做好对系统的清理工作。
一.清理CentOS7下的MariaDB。
[root@localhost~]#rpm-qa|grempmariadb
二.下载MySQL的yum包
Linux系统自带的repo是不会自动更新每个软件的最新版本(基本都是比较靠后的稳定版),所以无法通过yum方式安装MySQL的高级版本。所以我们需要先安装带有当前可用的mysql5系列社区版资源的rpm包(确保电脑联网)。
[root@localhost~]#wgethttp://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
[root@localhost~]#rpm-ivhmysql-community-release-el7-5.noarch.rpm
查看当前可用的mysql安装资源
安装mysql
[root@localhost~]#yuminstallmysql-community-server
已加载插件:fastestmirror,langpacks
base|3.6kB00:00
extras|3.4kB00:00
mysql-connectors-community|2.5kB00:00
mysql-tools-community|2.5kB00:00
mysql56-community|2.5kB00:00
updates|3.4kB00:00
(1/5):extras/7/x86_64/primary_db|117kB00:00
(2/5):mysql-connectors-community/x86_64/primary_db|9.8kB00:00
(3/5):mysql-tools-community/x86_64/primary_db|25kB00:01
(4/5):mysql56-community/x86_64/primary_db|115kB00:01
(5/5):updates/7/x86_64/primary_db|3.9MB00:01
Determiningfastestmirrors
*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-serverx86_645.6.29-2.el7mysql56-community58M
为依赖而安装:
mysql-community-clientx86_645.6.29-2.el7mysql56-community19M
mysql-community-commonx86_645.6.29-2.el7mysql56-community256k
mysql-community-libsx86_645.6.29-2.el7mysql56-community2.0M
事务概要
=================================================================
安装1软件包(+3依赖软件包)
总下载量:79M
安装大小:344M
Isthisok[y/d/N]:y
Downloadingpackages:
警告:/var/cache/yum/x86_64/7/mysql56-community/packages/mysql-community-common-5.6.29-2.el7.x86_64.rpm:头V3DSA/SHA1Signature,密钥ID5072e1f5: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|256kB00:01
(2/4):mysql-community-libs-5.6.29-2.el7.x86_64.rpm|2.0MB00:02
(3/4):mysql-community-server-5.6.29-2.el7.x86_64.rpm|58MB00: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:[Errno12]Timeoutonhttp://repo.mysql.com/yum/mysql-5.6-community/el/7/x86_64/mysql-community-client-5.6.29-2.el7.x86_64.rpm:(28,'Operationtooslow.Lessthan1000bytes/sectransferredthelast30seconds')
正在尝试其它镜像。
(4/4):mysql-community-client-5.6.29-2.el7.x86_64.rpm|19MB12:12
-----------------------------------------------------------------
总计105kB/s|79MB12:51
从file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql检索密钥
导入GPGkey0x5072E1F5:
用户ID:"MySQLReleaseEngineering<mysql-build@oss.oracle.com>"
指纹:a4a9406876fcbd3c456770c88c718d3b5072e1f5
软件包:mysql-community-release-el7-5.noarch(installed)
来自:file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
是否继续?[y/N]:y
Runningtransactioncheck
Runningtransactiontest
Transactiontestsucceeded
Runningtransaction
警告:RPM数据库已被非yum程序修改。
正在安装:mysql-community-common-5.6.29-2.el7.x86_641/4
正在安装:mysql-community-libs-5.6.29-2.el7.x86_642/4
正在安装:mysql-community-client-5.6.29-2.el7.x86_643/4
正在安装:mysql-community-server-5.6.29-2.el7.x86_644/4
warning:/etc/my.cnfcreatedas/etc/my.cnf.rpmnew
验证中:mysql-community-common-5.6.29-2.el7.x86_641/4
验证中:mysql-community-libs-5.6.29-2.el7.x86_642/4
验证中:mysql-community-client-5.6.29-2.el7.x86_643/4
验证中:mysql-community-server-5.6.29-2.el7.x86_644/4
已安装:
mysql-community-server.x86_640:5.6.29-2.el7
作为依赖被安装:
mysql-community-client.x86_640:5.6.29-2.el7
mysql-community-common.x86_640:5.6.29-2.el7
mysql-community-libs.x86_640:5.6.29-2.el7
完毕!
三.MySQL安装完成后,进行相关配置
四.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下的MariaDB。
[root@localhost~]#rpm-qa|grempmariadb
[root@localhost~]#rpm-e--nodepsmariadb.x86_64[code]1:5.5.41-2.el7_0[/code]
二.下载MySQL的yum包
Linux系统自带的repo是不会自动更新每个软件的最新版本(基本都是比较靠后的稳定版),所以无法通过yum方式安装MySQL的高级版本。所以我们需要先安装带有当前可用的mysql5系列社区版资源的rpm包(确保电脑联网)。
[root@localhost~]#wget
[root@localhost~]#rpm-ivhmysql-community-release-el7-5.noarch.rpm
查看当前可用的mysql安装资源
[root@localhost~]#yumrepolistenabled|grep"mysql.*-community.*"
mysql-connectors-community/x86_64MySQLConnectorsCommunity21
mysql-tools-community/x86_64MySQLToolsCommunity33
mysql56-community/x86_64MySQL5.6CommunityServer214
安装mysql
[root@localhost~]#yuminstallmysql-community-server
已加载插件:fastestmirror,langpacks
base|3.6kB00:00
extras|3.4kB00:00
mysql-connectors-community|2.5kB00:00
mysql-tools-community|2.5kB00:00
mysql56-community|2.5kB00:00
updates|3.4kB00:00
(1/5):extras/7/x86_64/primary_db|117kB00:00
(2/5):mysql-connectors-community/x86_64/primary_db|9.8kB00:00
(3/5):mysql-tools-community/x86_64/primary_db|25kB00:01
(4/5):mysql56-community/x86_64/primary_db|115kB00:01
(5/5):updates/7/x86_64/primary_db|3.9MB00:01
Determiningfastestmirrors
*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-serverx86_645.6.29-2.el7mysql56-community58M
为依赖而安装:
mysql-community-clientx86_645.6.29-2.el7mysql56-community19M
mysql-community-commonx86_645.6.29-2.el7mysql56-community256k
mysql-community-libsx86_645.6.29-2.el7mysql56-community2.0M
事务概要
=================================================================
安装1软件包(+3依赖软件包)
总下载量:79M
安装大小:344M
Isthisok[y/d/N]:y
Downloadingpackages:
警告:/var/cache/yum/x86_64/7/mysql56-community/packages/mysql-community-common-5.6.29-2.el7.x86_64.rpm:头V3DSA/SHA1Signature,密钥ID5072e1f5: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|256kB00:01
(2/4):mysql-community-libs-5.6.29-2.el7.x86_64.rpm|2.0MB00:02
(3/4):mysql-community-server-5.6.29-2.el7.x86_64.rpm|58MB00:29
mysql-community-client-5.6.29-FAILED
正在尝试其它镜像。
(4/4):mysql-community-client-5.6.29-2.el7.x86_64.rpm|19MB12:12
-----------------------------------------------------------------
总计105kB/s|79MB12:51
从file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql检索密钥
导入GPGkey0x5072E1F5:
用户ID:"MySQLReleaseEngineering<mysql-build@oss.oracle.com>"
指纹:a4a9406876fcbd3c456770c88c718d3b5072e1f5
软件包:mysql-community-release-el7-5.noarch(installed)
来自:file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
是否继续?[y/N]:y
Runningtransactioncheck
Runningtransactiontest
Transactiontestsucceeded
Runningtransaction
警告:RPM数据库已被非yum程序修改。
正在安装:mysql-community-common-5.6.29-2.el7.x86_641/4
正在安装:mysql-community-libs-5.6.29-2.el7.x86_642/4
正在安装:mysql-community-client-5.6.29-2.el7.x86_643/4
正在安装:mysql-community-server-5.6.29-2.el7.x86_644/4
warning:/etc/my.cnfcreatedas/etc/my.cnf.rpmnew
验证中:mysql-community-common-5.6.29-2.el7.x86_641/4
验证中:mysql-community-libs-5.6.29-2.el7.x86_642/4
验证中:mysql-community-client-5.6.29-2.el7.x86_643/4
验证中:mysql-community-server-5.6.29-2.el7.x86_644/4
已安装:
mysql-community-server.x86_640:5.6.29-2.el7
作为依赖被安装:
mysql-community-client.x86_640:5.6.29-2.el7
mysql-community-common.x86_640:5.6.29-2.el7
mysql-community-libs.x86_640:5.6.29-2.el7
完毕!
三.MySQL安装完成后,进行相关配置
a)[code]#######安装成功后,将其加入开机启动
systemctlenablemysqld
b)
#######
启动mysql服务进程
systemctlstartmysqld[/code]
c)#######配置mysql(设置密码等)
mysql_secure_installation
NOTE:RUNNINGALLPARTSOFTHISSCRIPTISRECOMMENDEDFORALLMySQL
SERVERSINPRODUCTIONUSE!PLEASEREADEACHSTEPCAREFULLY!
InordertologintoMySQLtosecureit,we'llneedthecurrent
passwordfortherootuser.Ifyou'vejustinstalledMySQL,and
youhaven'tsettherootpasswordyet,thepasswordwillbeblank,
soyoushouldjustpressenterhere.
Entercurrentpasswordforroot(enterfornone):
OK,successfullyusedpassword,movingon...
SettingtherootpasswordensuresthatnobodycanlogintotheMySQL
rootuserwithouttheproperauthorisation.
Setrootpassword?[Y/n]y[设置root用户密码]
Newpassword:
Re-enternewpassword:
Passwordupdatedsuccessfully!
Reloadingprivilegetables..
...Success!
Bydefault,aMySQLinstallationhasananonymoususer,allowinganyone
tologintoMySQLwithouthavingtohaveauseraccountcreatedfor
them.Thisisintendedonlyfortesting,andtomaketheinstallation
goabitsmoother.Youshouldremovethembeforemovingintoa
productionenvironment.
Removeanonymoususers?[Y/n]y[删除匿名用户]
...Success!
Normally,rootshouldonlybeallowedtoconnectfrom'localhost'.This
ensuresthatsomeonecannotguessattherootpasswordfromthenetwork.
Disallowrootloginremotely?[Y/n]y[禁止root远程登录]
...Success!
Bydefault,MySQLcomeswithadatabasenamed'test'thatanyonecan
access.Thisisalsointendedonlyfortesting,andshouldberemoved
beforemovingintoaproductionenvironment.
Removetestdatabaseandaccesstoit?[Y/n]y[删除test数据库]
-Droppingtestdatabase...
ERROR1008(HY000)atline1:Can'tdropdatabase'test';[code]databasedoesn'texist
...Failed!Notcritical,keepmoving...
-Removingprivilegesontestdatabase...
...Success!
Reloadingtheprivilegetableswillensurethatallchangesmadesofar
willtakeeffectimmediately.
Reloadprivilegetablesnow?[Y/n]y[刷新权限][/code]
...Success!
Alldone!Ifyou'vecompletedalloftheabovesteps,yourMySQL
installationshouldnowbesecure.
ThanksforusingMySQL!
Cleaningup...
四.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
相关文章推荐
- Linux上安装部署WildFly 10
- linux安全第七周总结
- 1.linux基本I/O接口介绍
- 《Linux内核设计与实现》第三章读书笔记
- linux安全第六周总结
- linux下nohup的后台启动程序
- Linux中使用cut命令来提取文本的用法指南
- CentOS 6.3 配置VNCServer 5.0.3
- Linux内核如何装载和启动一个可执行程序
- Linux下进程的同步相互排斥实例——生产者消费者
- Linux中stat命令显示文件的基本使用教程
- CentOS 6源码编译安装 PHP 7.0.5
- Linux菜鸟必学的60个命令
- linux logrotate配置
- linux的crontab等命令
- Mac下如何用SSH连接远程Linux服务器
- Centos配置本地yum源
- The Definitive Guide to Linux System Calls
- 【mysql学习】linux安装mysql
- linux下升级gcc的方法