mysql5.7報錯 1546、1577和1682問題分析

環境說明:
MySQL5.6.40 上xtrabackup全備備份的數據導入到mysql5.7.24實例上,啓動MySQL5.7的服務,登錄數據庫MySQL5.7實例。但是在drop user user@'127.0.0.1'時,報錯如下:

2019-08-15T19:02:31.160910+08:00 1546 [ERROR] /usr/local/mysql5.7/bin/mysqld: Column count of mysql.user is wrong. Expected 45, found 43. Created with MySQL 50640, now running 50724. Please use mysql_upgrade to fix this error.

mysql實例版本如下:

[root@e ~]# /usr/local/mysql/bin/mysqld -V
/usr/local/mysql/bin/mysqld  Ver 5.6.40 for Linux on x86_64 (Source distribution)
[root@e ~]# /usr/local/mysql5.7/bin/mysqld -V
/usr/local/mysql5.7/bin/mysqld  Ver 5.7.24 for linux-glibc2.12 on x86_64 (MySQL Community Server (GPL))

解決辦法:升級下MySQL5.7


/usr/local/mysql5.7/bin/mysql_upgrade -uroot -p'ln.orge#dieurw5199' -S /tmp/3306.sock
Checking if update is needed.
Checking server version.
Running queries to upgrade MySQL server.
Checking system database.

testdb29.dtr_wx_gotourl                             OK
testdb29.dtr_zone                                   OK
testdb29.hm_planstats_h                            OK
Upgrade process completed successfully.
Checking if update is needed.

登錄MySQL5.7刪除庫的用戶,刪除成功

mysql> drop user backupuser@'127.0.0.1';
Query OK, 0 rows affected (0.00 sec)

提示:此時的mysql5.7.24實例並沒有重啓

此刻創建一個定時器調用存儲過程時,報錯如下:

mysql> CREATE EVENT test1
    -> ON SCHEDULE EVERY 2 second STARTS TIMESTAMP '2019-08-10 16:16:22'
    -> ON COMPLETION PRESERVE
    -> DO
    -> BEGIN
    -> CALL test1();
    -> END//

ERROR 1577 (HY000): Cannot proceed because system tables used by Event Scheduler were found damaged at server start
mysql> show events;
ERROR 1577 (HY000): Cannot proceed because system tables used by Event Scheduler were found damaged at server start

###提示無法繼續,因爲在服務器啓動時發現事件調度程序使用的系統表已損壞

此刻查看mysql 系統變量報錯如下:

mysql> show variables like 'event_scheduler';
ERROR 1682 (HY000): Native table 'performance_schema'.'session_variables' has the wrong structure

出現的原因是我升級了mysql的版本,但是沒有重啓mysql實例
需要重啓MySQL5.7.24服務。否則會導致MySQL的部分系統表識別不到。

service restart mysql5.7.24

到此處問題解決了

mysql> show events;
Empty set (0.00 sec)

mysql> show variables like 'event_scheduler';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| event_scheduler | ON    |
+-----------------+-------+
1 row in set (0.01 sec)

從新創建定時器,執行成功:

mysql> CREATE PROCEDURE test1() 
    -> BEGIN
    -> INSERT INTO tb01(username,password,create_time) values('李四', '張三',now());
    -> END//
Query OK, 0 rows affected (0.01 sec)

mysql> CREATE EVENT test1
    -> ON SCHEDULE EVERY 5 second STARTS TIMESTAMP '2019-08-16 17:34:22'
    -> ON COMPLETION PRESERVE
    -> DO
    -> BEGIN
    -> CALL test1();
    -> END//
Query OK, 0 rows affected (0.00 sec)

mysql> delimiter ; 
mysql> select now();
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章