mysql5.6升級5.7
將數據庫從5.6.35升級到5.7.22mysql安裝目錄 /usr/local/mysql/數據目錄/data
1.准備工作
下載5.7.22版本mysql並解壓[root@localhost ~]# wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.22-el7-x86_64.tar.gz[root@localhost ~]#tar -zxvf mysql-5.7.22-el7-x86_64.tar.gz -C /usr/local/[root@localhost ~]#cd /usr/local/[root@localhost ~]#mv mysql-5.7.22-el7-x86_64/ mysql57
停止數據庫[root@localhost ~]# service mysql stopShutting down MySQL. SUCCESS!
將數據庫和所有數據備份安裝目錄備份[root@localhost ~]# cp -rp /usr/local/mysql /usr/local/mysql56數據備份[root@localhost ~]# cd /[root@localhost /]# cp -rp data data56啟動文件備份[root@localhost /]# cd /etc/init.d/[root@localhost init.d]# cp mysql mysql56配置文件備份[root@localhost init.d]# cp /etc/my.cnf /etc/my.cnf_56
2.數據庫升級
原數據庫信息5.6.35
①刪除原basedir並替換
[root@localhost ~]# cd /usr/local/[root@localhost local]# lsbin games lib libexec mysql56 sbin srcetc include lib64 mysql mysql57 share[root@localhost local]# rm -rf mysql[root@localhost local]# mv mysql57 mysql記得修改新mysql權限[root@localhost local]# chown -R mysql.mysql mysql
②替換新版mysql啟動腳本
[root@localhost local]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqlcp: overwrite ‘/etc/init.d/mysql’? y[root@localhost local]# vim /etc/init.d/mysql編寫新啟動腳本 將basedir和datadir填寫進去
basedir=/usr/local/mysql
datadir=/data
③啟動mysql
[root@localhost local]# service mysql startStarting MySQL… SUCCESS! 查看進程和端口確認啟動
④升級數據字典
[root@localhost local]# /usr/local/mysql/bin/mysql_upgrade -uroot -pEnter password:Checking if update is needed.Checking server version.Running queries to upgrade MySQL server.Checking system database.mysql.columns_priv OKmysql.db OKmysql.engine_cost OKmysql.event OKmysql.func OKmysql.general_log OKmysql.gtid_executed OKmysql.help_category OKmysql.help_keyword OKmysql.help_relation OKmysql.help_topic OKmysql.innodb_index_stats OKmysql.innodb_table_stats OKmysql.ndb_binlog_index OKmysql.plugin OKmysql.proc OKmysql.procs_priv OKmysql.proxies_priv OKmysql.server_cost OKmysql.servers OKmysql.slave_master_info OKmysql.slave_relay_log_info OKmysql.slave_worker_info OKmysql.slow_log OKmysql.tables_priv OKmysql.time_zone OKmysql.time_zone_leap_second OKmysql.time_zone_name OKmysql.time_zone_transition OKmysql.time_zone_transition_type OKmysql.user OKChecking databases.sys.sys_config OKUpgrade process completed successfully.Checking if update is needed.
⑤重啟啟動mysql並驗證
[root@localhost local]# service mysql restartShutting down MySQL… SUCCESS! Starting MySQL. SUCCESS!
可以看到數據庫已經升級到5.7.22了