Mysql从5.6.14安全升级至mysql5.6.25的方法
服务器上Mysql的版本为:社区版的mysql-community-server-5.6.14。近日局方对服务器进行漏洞扫描,发现zhyh08上的mysql存在几个高危漏洞,要求进行修复。受这几个漏洞影响的主要是5.6.17及以前的版本,所以将mysql升级至最新的5.6.25即可解决问题。
1、下载最新的mysql安装包(rpm文件),链接如下:
MySQL-5.6.25-1.el6.x86_64.rpm-bundle.tar
2、备份数据库数据,这里使用的是mysqldump命令。
3、备份/etc/my.cnf:cp/etc/my.cnf/etc/my.cnf_backup
3、停止mysql服务:servicemysqlstop
4、解压上面的tar包:tar-xvfMySQL-5.6.25-1.el6.x86_64.rpm-bundle.tar
5、确认服务器上所安装的mysql的各个组件,这里我们只升级server和client。
[hadoop@zlyh08chx]$rpm-qa|grep-imysql mysql-community-libs-compat-5.6.14-3.el6.x86_64 mysql-community-devel-5.6.14-3.el6.x86_64 mysql-community-common-5.6.14-3.el6.x86_64 mysql-community-libs-5.6.14-3.el6.x86_64 mysql-community-server-5.6.14-3.el6.x86_64 mysql-community-client-5.6.14-3.el6.x86_64 perl-DBD-MySQL-4.013-3.el6.x86_64 [hadoop@zlyh08chx]$
6、将server和client卸载:
rpm-emysql-community-server-5.6.14-3.el6.x86_64 rpm-emysql-community-client-5.6.14-3.el6.x86_64
注:如若不先卸载的话,安装时会报文件冲突:
[root@zlyh08chx]#rpm-UvhMySQL-server-5.6.25-1.el6.x86_64.rpm Preparing...###########################################[100%] file/usr/share/mysql/bulgarian/errmsg.sysfrominstallofMySQL-server-5.6.25-1.el6.x86_64conflictswithfilefrompackagemysql-community-common-5.6.14-3.el6.x86_64 ………… file/usr/share/mysql/french/errmsg.sysfrominstallofMySQL-server-5.6.25-1.el6.x86_64conflictswithfilefrompackagemysql-community-common-5.6.14-3.el6.x86_64
7、重新安装server和client:
[root@zlyh08chx]#rpm-ivhMySQL-server-5.6.25-1.el6.x86_64.rpm Preparing...###########################################[100%] 1:MySQL-server###########################################[100%] 2015-07-0116:02:400[Warning]TIMESTAMPwithimplicitDEFAULTvalueisdeprecated.Pleaseuse--explicit_defaults_for_timestampserveroption(seedocumentationformoredetails). 2015-07-0116:02:400[Note]/usr/sbin/mysqld(mysqld5.6.25)startingasprocess28611... 2015-07-0116:02:4028611[Note]InnoDB:Usingatomicstorefcountbufferpoolpages 2015-07-0116:02:4028611[Note]InnoDB:TheInnoDBmemoryheapisdisabled ………… 2015-07-0116:02:4428633[Note]InnoDB:FTSoptimizethreadexiting. 2015-07-0116:02:4428633[Note]InnoDB:Startingshutdown... 2015-07-0116:02:4528633[Note]InnoDB:Shutdowncompleted;logsequencenumber1625987 ARANDOMPASSWORDHASBEENSETFORTHEMySQLrootUSER! Youwillfindthatpasswordin'/root/.mysql_secret'.#竟然没发现这一行,难怪装完一直连不上 ---------- [root@appserver~]#cat/root/.mysql_secret #TherandompasswordsetfortherootuseratThuNov2015:52:022014(localtime):sFpJCf6WLhyYKc35 ---------- Youmustchangethatpasswordonyourfirstconnect, nootherstatementbut'SETPASSWORD'willbeaccepted. Seethemanualforthesemanticsofthe'passwordexpired'flag. Also,theaccountfortheanonymoususerhasbeenremoved. Inaddition,youcanrun: /usr/bin/mysql_secure_installation whichwillalsogiveyoutheoptionofremovingthetestdatabase. Thisisstronglyrecommendedforproductionservers. Seethemanualformoreinstructions. Pleasereportanyproblemsathttp://bugs.mysql.com/ ThelatestinformationaboutMySQLisavailableonthewebat http://www.mysql.com SupportMySQLbybuyingsupport/licensesathttp://shop.mysql.com Newdefaultconfigfilewascreatedas/usr/my.cnfand willbeusedbydefaultbytheserverwhenyoustartit. Youmayeditthisfiletochangeserversettings [root@zlyh08chx]#rpm-ivhMySQL-client-5.6.25-1.el6.x86_64.rpm Preparing...###########################################[100%] 1:MySQL-client###########################################[100%] [root@zlyh08chx]#
8、恢复my.cnf:cp/etc/my.cnf_backup/etc/my.cnf
9、启动mysql服务:servicemysqlstart
[root@zlyh08chx]#servicemysqlstart StartingMySQL...SUCCESS!
10、使用客户端连接mysql:
[root@zlyh08mysql-5.6.25]#mysql ERROR2002(HY000):CantconnecttolocalMySQLserverthroughsocket'/data1/mysql/mysql.sock'(2)
11、查看/data1/mysql目录下,确实没有mysql.sock文件。
12、查看/etc/my.cnf文件,发现只在[mysql]下面配置了
[mysql] socket=/data1/mysql/mysql.sock default-character-set=utf8 [mysqld]#mysqld下面没有配置socket #skip-grant-tables interactive_timeout=300 wait_timeout=300
13、编辑/etc/my.cnf,在[mysqld]下面添加socket的配置,使用服务器和客户端都使用同一个socket文件,如下:
[mysql] socket=/data1/mysql/mysql.sock default-character-set=utf8 [mysqld] #skip-grant-tables socket=/data1/mysql/mysql.sock#增加此行,之前只[mysql]加了这一项 interactive_timeout=300 wait_timeout=300
14、重启mysql服务。
15、使用升级前的root用户连接mysql:
[hadoop@zlyh08report_script]$mysql-hzlyh08-uroot-p Enterpassword: WelcometotheMySQLmonitor.Commandsendwith;or\g. YourMySQLconnectionidis233 Serverversion:5.6.25MySQLCommunityServer(GPL) Copyright(c)2000,2015,Oracleand/oritsaffiliates.Allrightsreserved. OracleisaregisteredtrademarkofOracleCorporationand/orits affiliates.Othernamesmaybetrademarksoftheirrespective owners. Type'help;'or'\h'forhelp.Type'\c'toclearthecurrentinputstatement. mysql>showdatabases; +--------------------+ |Database| +--------------------+ |information_schema| |apollo_v1.0| |hive| |log| |metastore| |mysql| |oozie| |performance_schema| |test| +--------------------+ 9rowsinset(0.00sec) mysql>
16、至此,升级完成。
以上所述是小编给大家介绍的Mysql从5.6.14安全升级至mysql5.6.25的方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对毛票票网站的支持!