Table ‘mysql.innodb_index_stats’ doesn’t exist in engine. mysql.innodb_index_stats not found

Error: Table “mysql”.”innodb_index_stats” not found. Table ‘mysql.innodb_index_stats’ doesn’t exist in engine.

 
I saw the above error message when I checked the mySQL error logs. Error shows that a table on your server is missing. Do the below steps to fix the issue.

1. Log into your Linux Server via SSH as ‘root’

2. Take a backup of the mySQL database

mysqldump mysql > /usr/local/src/mysql.sql

3. Before creating the tables, First you must DROP the table innodb_index_stats using below steps

mysql>

mysql> use mysql;
Database changed

mysql>drop table innodb_index_stats;

4. Go to /var/lib/mysql/mysql directory and rename “innodb_index_stats.ibd” using below command

mv innodb_index_stats.ibd innodb_index_stats.ibd.bakk
 


 
5. Log into mysql and create the table “innodb_index_stats” using the below command

mysql>use mysql;
mysql>CREATE TABLE `innodb_index_stats` (
`database_name` varchar(64) COLLATE utf8_bin NOT NULL,
`table_name` varchar(64) COLLATE utf8_bin NOT NULL,
`index_name` varchar(64) COLLATE utf8_bin NOT NULL,
`last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`stat_name` varchar(64) COLLATE utf8_bin NOT NULL,
`stat_value` bigint(20) unsigned NOT NULL,
`sample_size` bigint(20) unsigned DEFAULT NULL,
`stat_description` varchar(1024) COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`database_name`,`table_name`,`index_name`,`stat_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin STATS_PERSISTENT=0;
 


 
You might see the below errors and that is the reason why I suggested to rename the ibd file and drop the database.

————–
ERROR 1813 (HY000): Tablespace for table ‘`mysql`.`innodb_index_stats`’ exists. Please DISCARD the tablespace before IMPORT.

Table ‘innodb_index_stats’ already exists
mv innodb_index_stats.ibd innodb_index_stats.ibd.bakk
————–