mysql5.6怎么升级到mysql5.7,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。

1、停止mysql5.6数据库服务

[root@host2mysql]#/etc/init.d/mysqldstopShuttingdownMySQL..[OK][root@host2mysql]#


2、进入/usr/local更换软连接指定到mysql5.7

[root@host2local]#lsbingamesliblibexecmysqlmysql-5.7.16-linux-glibc2.5-x86_64mysql-utilities-1.6.5.tar.gzshareetcincludelib64my.cnfmysql-5.6.34-linux-glibc2.5-x86_64mysql-utilities-1.6.5sbinsrc[root@host2local]#unlinkmysql


创建新的链接

[root@host2local]#ln-smysql-5.7.16-linux-glibc2.5-x86_64mysql[root@host2local]#lltotal712drwxr-xr-x.2rootroot4096Jun282011bindrwxr-xr-x.2rootroot4096Jun282011etcdrwxr-xr-x.2rootroot4096Jun282011gamesdrwxr-xr-x.2rootroot4096Jun282011includedrwxr-xr-x.2rootroot4096Jun282011libdrwxr-xr-x.2rootroot4096Jun282011lib64drwxr-xr-x.2rootroot4096Jun282011libexec-rw-r--r--.1rootroot2754Nov615:44my.cnflrwxrwxrwx.1rootroot34Mar815:34mysql->mysql-5.7.16-linux-glibc2.5-x86_64drwxr-xr-x.12mysqlmysql4096Feb2718:33mysql-5.6.34-linux-glibc2.5-x86_64drwxr-xr-x.11rootmysql4096Nov1900:01mysql-5.7.16-linux-glibc2.5-x86_64drwxr-xr-x.77161314154096Feb2802:00mysql-utilities-1.6.5-rw-r--r--.1rootroot668241Feb2801:59mysql-utilities-1.6.5.tar.gzdrwxr-xr-x.2rootroot4096Jun282011sbindrwxr-xr-x.5rootroot4096Nov622:15sharedrwxr-xr-x.2rootroot4096Jun282011src


3、启动数据库并进入数据库

[root@host2local]#/etc/init.d/mysqldstartStartingMySQL.............................................[OK]..............................[root@host2local]#mysql-uroot-pEnterpassword:WelcometotheMySQLmonitor.Commandsendwith;or\g.YourMySQLconnectionidis2Serverversion:5.7.16-logMySQLCommunityServer(GPL)



(可以看到数据库已经到5.7版本了)

Copyright(c)2000,2016,Oracleand/oritsaffiliates.Allrightsreserved.OracleisaregisteredtrademarkofOracleCorporationand/oritsaffiliates.Othernamesmaybetrademarksoftheirrespectiveowners.Type'help;'or'\h'forhelp.Type'\c'toclearthecurrentinputstatement.mysql>


4、更新数据结构(生产环境使用mysql_upgrade更新的时候加-s参数 不重建表)

[root@host2local]#mysql_upgrade-p123-smysql_upgrade:[Warning]Usingapasswordonthecommandlineinterfacecanbeinsecure.The--upgrade-system-tablesoptionwasused,databaseswon'tbetouched.Checkingifupdateisneeded.Checkingserverversion.RunningqueriestoupgradeMySQLserver.Upgradingthesysschema.Upgradeprocesscompletedsuccessfully.Checkingifupdateisneeded.


至此升级成功
5、进入数据库查看

mysql>showdatabases;+--------------------+|Database|+--------------------+|information_schema||mysql||performance_schema||sys||test|+--------------------+可以看到sys库已经存在,但是直接安装的5.7的库是没有test库的,这里sys和test同时存在说明是从5.6升级到5.7

看完上述内容,你们掌握mysql5.6怎么升级到mysql5.7的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注亿速云行业资讯频道,感谢各位的阅读!