'mysql.column_stats' doesn't exist and Table 'mysql.index_stats' doesn't exist

在生产库MariabDB中修改字段类型,提示如下错误:
?Table ‘mysql.column_stats‘ doesn‘t exist
Table ‘mysql.index_stats‘ doesn‘t exist

?MariaDB版本如下:?
?MariaDB [mysql]> select @@version;
+---------------------+
| @@version |
+---------------------+
| 10.0.12-MariaDB-log |
+---------------------+

连接mysql数据库检查表:
MariaDB [mysql]> show tables;
+---------------------------+
| Tables_in_mysql |
+---------------------------+
| columns_priv |
| db |
| event |
| func |
| general_log |
| gtid_slave_pos |
| help_category |
| help_keyword |
| help_relation |
| help_topic |
| host |
| innodb_index_stats |
| innodb_table_stats |
| inventory |
| ndb_binlog_index |
| plugin |
| proc |
| procs_priv |
| proxies_priv |
| servers |
| slave_master_info |
| slave_relay_log_info |
| slave_worker_info |
| slow_log |
| tables_priv |
| time_zone |
| time_zone_leap_second |
| time_zone_name |
| time_zone_transition |
| time_zone_transition_type |
| user |
+---------------------------+

检查发现缺少提示错误的几张表,column_stats、index_stats、table_stats

解决方法:
在主库创建以上表:
CREATE TABLE IF NOT EXISTS `column_stats` (
`db_name` varchar(64) NOT NULL COMMENT ‘Database the table is in.‘,
`table_name` varchar(64) NOT NULL COMMENT ‘Table name.‘,
`column_name` varchar(64) NOT NULL COMMENT ‘Name of the column.‘,
`min_value` varchar(255) DEFAULT NULL COMMENT ‘Minimum value in the table (in text form).‘,
`max_value` varchar(255) NOT NULL COMMENT ‘Maximum value in the table (in text form).‘,
`nulls_ratio` decimal(12,4) DEFAULT NULL COMMENT ‘Fraction of NULL values (0 - no NULLs, 0.5 - half values are NULLs, 1 - all values are NULLs).‘,
`avg_length` decimal(12,4) DEFAULT NULL COMMENT ‘Average length of column value, in bytes. Counted as if one ran SELECT AVG(LENGTH(col)). This doesn‘‘t count NULL bytes, assumes endspace removal for CHAR(n), etc.‘,
`avg_frequency` decimal(12,4) DEFAULT NULL COMMENT ‘Average number of records with the same value‘,
`hist_size` tinyint(3) unsigned DEFAULT NULL COMMENT ‘Histogram size in bytes, from 0-255.‘,
`hist_type` enum(‘SINGLE_PREC_HB‘,‘DOUBLE_PREC_HB‘) DEFAULT NULL COMMENT ‘Histogram type. See the histogram_type system variable.‘,
`histogram` varbinary(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `index_stats` (
`db_name` varchar(64) NOT NULL COMMENT ‘Database the table is in.‘,
`table_name` varchar(64) NOT NULL COMMENT ‘Table name‘,
`index_name` varchar(64) NOT NULL COMMENT ‘Name of the index‘,
`prefix_arity` int(10) unsigned NOT NULL COMMENT ‘Index prefix length. 1 for the first keypart, 2 for the first two, and so on. InnoDB‘‘s extended keys are supported.‘,
`avg_frequency` decimal(12,4) DEFAULT NULL COMMENT ‘Average number of records one will find for given values of (keypart1, keypart2, ..), provided the values will be found in the table.‘
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `table_stats` (
`db_name` varchar(64) NOT NULL COMMENT ‘Database the table is in .‘,
`table_name` varchar(64) NOT NULL COMMENT ‘Table name.‘,
`cardinality` bigint(21) DEFAULT NULL COMMENT ‘Number of records in the table.‘
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

ALTER TABLE `column_stats`
ADD PRIMARY KEY (`db_name`,`table_name`,`column_name`);

ALTER TABLE `index_stats`
ADD PRIMARY KEY (`db_name`,`table_name`,`index_name`,`prefix_arity`);

ALTER TABLE `table_stats`
ADD PRIMARY KEY (`db_name`,`table_name`);

'mysql.column_stats' doesn't exist and Table 'mysql.index_stats' doesn't exist

时间: 2024-10-24 19:05:47

'mysql.column_stats' doesn't exist and Table 'mysql.index_stats' doesn't exist的相关文章

解决mysql插入数据报错[Err] 1146 - Table 'performance_schema.session_status' doesn't exist

解决办法:1.打开cmd 执行命令cd/ 进入C盘根目录2.dir 查看C盘根目录下文件夹  找到 Program Files文件夹3.cd Program Files 进入该文件夹下 再输入dir 查看该文件夹下所有文件夹4.cd MySQL 进入该文件夹  再输入dir 查看该文件夹下所有文件夹5.cd MySQLServer 5.7 进入该文件夹  再输入dir 查看该文件夹下所有文件夹6.cd bin 进入该文件夹  7.输入mysql_upgrade -u root -p --forc

Mysql innodb错误解决 InnoDB: Error: table `mysql`.`innodb_table_stats`

通过ELK监控发现,程序连接mysql DB 失败,通过看程序的log和mysql的error log发现mysql中出现error 查看Mysql日志 发现 InnoDB: Error: table `mysql`.`innodb_table_stats` does not exist in the InnoDB internal 这个原因很明显 ,是mysql库的innodb_table_stats表损坏了. 首先登录mysql查看表是否存在?   结果:存在的. Tables_in_mys

MySQL 5.6 解决InnoDB: Error: Table "mysql"."innodb_table_stats" not found.问题

在安装MySQL 5.6.30时,安装完成后,后台日志报如下警告信息:2016-05-27 12:25:27 7fabf86f7700 InnoDB: Error: Table "mysql"."innodb_table_stats" not found.2016-05-27 12:25:27 7fabf86f7700 InnoDB: Error: Fetch of persistent statistics requested for table "hj

InnoDB: Error: Table "mysql"."innodb_table_stats" not found.

1,Mysqldump的时候报错如下: 2014-05-05 14:12:37 7f004a9a2700 InnoDB: Error: Table "mysql"."innodb_table_stats" not found. 但是show tables我看这个表示存在的: 但是show create table innodb_index_stats;报错如下: mysql> show create table innodb_index_stats; ERRO

mysql启动报错:Fatal error: Can’t open and lock privilege tables: Table ‘mysql.host’ doesn’t exist

mysql在首次启动的时候可能会报错:Can’t open and lock privilege tables: Table ‘mysql.host’ doesn’t exist 这时候可以执行脚本 mysql_install_db –user=mysql –ldata=数据存放的路径

启动mysql问题Can't open and lock privilege tables: Table 'mysql.host' doesn't exist

启动mysql出现问题 /etc/init.d/mysqld start MySQL server PID file could not be found![FAILED] Starting MySQL......................................The server quit without updating PID file (/data/mysql/mysql_3306/data/mysql.pid).[FAILED] 查看错误日志 150619 15:57:

Failed to load slave replication state from table mysql.gtid_slave_pos: 1146: Table 'mysql.gtid_slave_pos' doesn't exist

http://anothermysqldba.blogspot.com/2013/06/mariadb-1003-alpha-install-on-fedora-17.html MariaDB 10.0.3 Alpha install on Fedora 17 x86_64 MariaDB 10.0.3 Alphawas just released. So for those of you that recall my previous MariaDB 5.5 install post, I d

[ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist

[[email protected] scripts]# ./mysql_install_db --user=mysql --basedir=/app/servers/mysql-5.5.20 --datadir=/app/servers/mysql-5.5.20/data/ 加上--datadir=/app/servers/mysql-5.5.20/data/ 问题解决!!! [ERROR] Fatal error: Can't open and lock privilege tables:

linux mysql启动报错Can't open and lock privilege tables: Table 'mysql.host' doesn't exist

vi /etc/my.cnf  查看日志文件路径: log-error=/var/log/mysqld.log 查看报错日志: 之前的服务器被别人拿了,所以自己买了台美国vps,根据笔记安装完启动mysql,又启动不了. 查看了错误日志 引用 090321 18:55:03 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data /usr/local/mysql/libexec/mysqld: Ta