升級的方法通常有兩類:mysql
1.利用mysqldump來直接導出sql文件,導入到新庫中,這種方法是最省事兒的,也是最保險的,缺點的話,也顯而易見,大庫的mysqldump費時費力。sql
2.直接替換掉mysql的安裝目錄和my.cnf,利用mysql_upgrade 來完成系統表的升級,這種方法須要備份原有的文件,但屬於物理拷貝,速度較快。缺點的話,跨版本升級不推薦這麼作,好比mysql5.1升級到mysql5.6,mysql5.5升級到mysql5.7等。數據庫
本文采用的是第二種方法升級。app
MySQL當前版本日誌
[root@localhost ~]# /usr/local/mysql/bin/mysql -V /usr/local/tdoa/mysql/bin/mysql Ver 14.14 Distrib 5.5.36, for Linux (x86_64) using readline 5.1
備份my.cnf、MySQL安裝目錄、MySQL數據目錄code
[root@localhost ~]# cp -p /etc/init.d/mysql /etc/init.d/mysql.old [root@localhost ~]# cp -p /etc/my.cnf /etc/my.cnf.old [root@localhost ~]# cp -rp /usr/local/mysql /usr/local/mysql.old [root@localhost ~]# rm -rf /usr/local/mysql
安裝最新版本的MySQLserver
[root@localhost ~]# tar xvf mysql-5.6.37.tar.gz [root@localhost ~]# cd mysql-5.6.37 [root@localhost ~]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/tdoa/mysql \ -DMYSQL_DATADIR=/usr/local/tdoa/data5 \ -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DEXTRA_CHARSETS=all \ -DDEFAULT_COLLATION=utf8_general_ci \ -DDEFAULT_CHARSET=utf8 \ -DMYSQL_TCP_PORT=3336 \ -DWITH_READLINE=1 \ -DENABLED_LOCAL_INFILE=1 \ -DMYSQL_USER=mysql \ -DWITH_DEBUG=0 [root@localhost ~]# make [root@localhost ~]# make install [root@localhost ~]# cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf [root@localhost ~]# cat /etc/my.cnf.old > /etc/my.cnf [root@localhost ~]# cp -p /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql [root@localhost ~]# /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/data5 [root@localhost ~]# chown mysql.mysql -R /usr/local/tdoa/mysql [root@localhost ~]# chown mysql.mysql -R /usr/local/tdoa/data5 [root@localhost ~]# /etc/init.d/mysql start [root@localhost ~]# ps -ef |grep mysql [root@localhost ~]# /etc/init.d/mysql stop [root@localhost ~]# /usr/local/data5 /usr/local/data5.newold [root@localhost ~]# mv /usr/local/data5.old /usr/local/data5 [root@localhost ~]# /etc/init.d/mysql start [root@localhost ~]# /usr/local/mysql/bin/mysql_upgrade -uroot -pxxxx
升級後的MySQL版本ip
[root@localhost ~]# /usr/local/tdoa/mysql/bin/mysql -V /usr/local/tdoa/mysql/bin/mysql Ver 14.14 Distrib 5.6.37, for Linux (x86_64) using EditLine wrapper
請保證一些路徑的設置和之前的my.cnf一致,若是設置錯誤,極可能致使啓動不了數據庫
[ERROR] Could not use /usr/local/data5/slowlog/slow.log for logging
我這裏是因爲慢日誌的位置和老的mysql5.6路徑不一致,建立/data/slowlog便可,這裏要仔細看報錯,而後根據報錯來發現和解決問題。ci