mysql從5.5直接升級到5.7后,執行mysql_upgrade速度很慢且執行結束后數據目錄大小增加一倍及 mysqlpump備份出現1577錯誤


mysql官網不支持誇大版本升級,比如跳過5.6直接升級到5.7,但由於一些客觀原因,項目需要從5.5直接升級到5.7,以下是具體操作

1、備份之前mysql,(數據量少,可直接拷貝安裝目錄及data目錄和配置文件,本例使用的為Percona XtraBackup工具進行的備份)

2、將data目錄移出mysql5.5安裝目錄

3、解壓mysql5.7版本

4、修改5.7需要配置文件my.cnf,添加datadir,指向5.5數據目錄

5、初始化,該步驟可選,(新安裝數據庫,或者數據目錄不存在,可執行如下命令初始化數據目錄,本例中不需要執行如下操作)

bin/mysqld --initialize --user=mysql

6、執行ssl相關操作

bin/mysql_ssl_rsa_setup

7、啟動mysql

8、此時數據目錄還是5.5的,需要執行mysql_upgrade進行升級,在執行表修復前,需要確認一個參數innodb_file_per_table,mysql官網對該參數的解釋如下

該參數在5.5版本默認為OFF,所有表和索引都導入一個共享文件中,名為ibdata1,但在5.6.7及以后版本,改參數被默認設置為ON,即每張表都有對應的表和索引存儲文件,每個schema下,每個frm文件都有對應的ibd文件。

在執行mysql_upgrade時,會修復系統表,並且如果該參數在5.5和5.7版本均使用默認值,則會將之前共享表和索引的存儲方式改為每張表單獨存儲表和索引的形式,故會出現拷貝復制的操作,如果數據量比較大,則用時就會很長,

使用nnodb_file_per_table=1,及表和索引單獨存儲的優缺點,可查看mysql官網介紹。

9、使用mysql_upgrade檢測並修復表

使用方法與mysql命令登錄命令行一樣,mysql會自動檢測當前表並自動修復

mysql_upgrade -uroot -p

10、修復完成后,若發現mysql啟動有server-key.pem相關的ssl錯誤,則是server-key.pem文件權限問題

chmod 644 server-key.pem

11、但此時若執行mysqlpum備份數據,可能會出現異常

mysqlpump --user=root --password mytest > mytest.sql

錯誤信息:

mysqlpump: [ERROR] (1577) Cannot proceed because system tables used by Event Scheduler were found damaged at server start
Dump process encountered error and will not continue.
mysqlpump: [ERROR] (1577) Cannot proceed because system tables used by Event Scheduler were found damaged at server start
Dump process encountered error and will not continue.
mysqlpump: [ERROR] (1577) Cannot proceed because system tables used by Event Scheduler were found damaged at server start
Dump process encountered error and will not continue.
mysqlpump: [ERROR] (1577) Cannot proceed because system tables used by Event Scheduler were found damaged at server start
Dump process encountered error and will not continue.
mysqlpump: [ERROR] (1577) Cannot proceed because system tables used by Event Scheduler were found damaged at server start
Dump process encountered error and will not continue.
mysqlpump: [ERROR] (1577) Cannot proceed because system tables used by Event Scheduler were found damaged at server start
Dump process encountered error and will not continue.
mysqlpump: [ERROR] (1577) Cannot proceed because system tables used by Event Scheduler were found damaged at server start
Dump process encountered error and will not continue.
mysqlpump: [ERROR] (1577) Cannot proceed because system tables used by Event Scheduler were found damaged at server start
Dump process encountered error and will not continue.
mysqlpump: [ERROR] (1577) Cannot proceed because system tables used by Event Scheduler were found damaged at server start
Dump process encountered error and will not continue.

解決方法:重啟mysql服務 (本例中是這樣解決的問題)

重新執行mysqlpump

Dump progress: 1/28 tables, 0/353 rows
Dump progress: 36/343 tables, 0/19746 rows
Dump progress: 180/343 tables, 6151/19746 rows
Dump completed in 3675 milliseconds

數據被正確備份下來,且備份速度很快,從備份文件可以看到,內容與mysqldump備份有很多不同

本次只是簡單嘗試mysqlpump,待后續再對mysqlpump做深入了解

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM