环境说明:
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();