
1. 异常描述
使用xtrabackup对主库进行备份,在从节点主机上进行恢复,并将还原后的实例部署为主库的从节点。在启动介质与主库版本一致的情况下,启动主从同步后,日志出现如下错误:
2022-10-30T11:44:17.442001Z 296 [ERROR] InnoDB: Column table_name in table `mysql`.`innodb_table_stats` is VARCHAR(597) NOT NULL but should be VARCHAR(192) NOT NULL (length mismatch).2022-10-30T11:44:17.442029Z 296 [ERROR] InnoDB: Fetch of persistent statistics requested for table `testdb1`.`tb1` but the required system tables mysql.innodb_table_stats and mysql.innodb_index_stats are not present or have unexpected structure. Using transient stats instead.2022-10-30T11:44:17.567223Z 296 [ERROR] InnoDB: Column table_name in table `mysql`.`innodb_table_stats` is VARCHAR(597) NOT NULL but should be VARCHAR(192) NOT NULL (length mismatch).2022-10-30T11:44:17.567240Z 296 [ERROR] InnoDB: Fetch of persistent statistics requested for table `testdb2`.`tb1` but the required system tables mysql.innodb_table_stats and mysql.innodb_index_stats are not present or have unexpected structure. Using transient stats instead.
/usr/local/mysql5.7/bin/mysqld_safe --defaults-file=/app/data/mysql3307/etc/my.cnf
[ops@ck2 ~]$ /usr/local/mysql5.7/bin/mysqld --version/usr/local/mysql5.7/bin/mysqld Ver 5.7.25-28 for Linux on x86_64 (Percona Server (GPL), Release 28, Revision c335905)
但是登录数据库中查看版本:

确实与启动的版本不一致。
2. 解决方案
查看本机上mysql是否有多个版本的启动文件
经查,确实如此。而第一个版本正式启动后数据库里检测到的版本。

2.1 解决思路
检查配置文件:
检查环境变量
export MYSQL_HOME=/app/mysql5.7export MY_BASEDIR_VERSION=/app/mysql5.7export PATH=/app/mysql5.7/bin:/app/mysql5.7/scripts:$PATHexport LD_LIBRARY_PATH=/app/mysql5.7/lib
发现环境变量里配置的确实是mysql5.7.18的路径。
2.2 调整环境变量
将对应的路径改为当前版本的路径
export MYSQL_HOME=/usr/local/mysql5.7export MY_BASEDIR_VERSION=/usr/local/mysql5.7export PATH=/usr/local/mysql5.7/bin:/usr/local/mysql5.7/scripts:$PATHexport LD_LIBRARY_PATH=/usr/local/mysql5.7/lib
2.3 重启数据库
关闭数据库
mysql> set global innodb_fast_shutdown=0;Query OK, 0 rows affected (0.00 sec)mysql> shutdown;
启动数据库
numactl --interleave=all usr/local/mysql5.7/bin/mysqld_safe --defaults-file=/app/data/mysql3307/etc/my.cnf &
查看版本,是预期的情况了。

检查配置文件: 也没有再出现对应的错误了,至此问题解决。

2. mysql8.0新增用户及加密规则修改的那些事
3. 比hive快10倍的大数据查询利器-- presto
4. 监控利器出鞘:Prometheus+Grafana监控MySQL、Redis数据库
5. PostgreSQL主从复制--物理复制
6. MySQL传统点位复制在线转为GTID模式复制




文章转载自数据库干货铺,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




