The Lazy Admin Blog

Home  /  MySQL  /  InnoDB: Failed to find tablespace for table `X` in the cache

InnoDB: Failed to find tablespace for table `X` in the cache

September 30, 2022 MySQL 1 Comment

MySQL service fails to start with the error “InnoDB: Failed to find tablespace for table `X` in the cache” –

2021-02-15 22:00:01 8 [ERROR] InnoDB: Failed to find tablespace for table `X`.`Y` in the cache. Attempting to load the tablespace with
 space id 100483

This most likely happens due to some kind of corruption in the Database that will prevent the entire MySQL service from starting. Our initial resolution will be to try and use the “innodb_force_recovery“, however in some edge cases this won’t work and we need to physically remove the affected DB from the system. We need to understand that most likely the affected database is lost, but we still need access to the MySQL service for other databases.

Assuming the MySQL service is down Let’s remove the affected DB from the MySQL data folder

mv /var/lib/mysql/DB_NAME /root

At this point, if we will try to start MySQL service we will most likely see –

2021-02-15 22:06:22 0 [ERROR] InnoDB: Tablespace 112219 was not found at ./DB_NAME/TABLE_NAME.ibd.
2021-02-15 22:06:22 0 [ERROR] InnoDB: Set innodb_force_recovery=1 to ignore this and to permanently lose all changes to the tablespace.

To clear all affected tablespace, add the following to “/etc/my.cnf” –

innodb_force_recovery=1
skip-grant-tables

You can try and start the MySQL service now. If this was successful, we can’t really work with MySQL while “innodb_force_recovery” is on, so you should stop the service, remove the added lines above and start it again.

Now that the service is started again, it is recommended to run “auto-repair” –

mysqlcheck -u root --auto-repair --all-databases

As we did a “hard cut” for the affected database, there are most likely some old references for it, so it is advised to create a database in the same exact name and drop it right after.

Now it’s time to restore your lost DB from backup!

Tags: InnoDB, MySQL
Previous Article
Next Article

Related Posts

  • Create MySQL database & user from cli

    Create MySQL database & user from cli

    April 14, 2016
  • Automated MySQL Installation

    Automated MySQL Installation

    April 14, 2016

1 Comment

  1. Anonymous Reply
    October 9, 2022 at 14:45

    This one is a lifesaver!

    I did tried the innodb_force_recovery first, but the idea of moving out the affected DB is great. I did lost that DB, but at least I could save the entire MySQL with the rest of the databases

Leave a Reply

Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Search Our Blog

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Filter by Categories
Apache
CentOS
CloudLinux
cPanel
Emails
ESXI
iSCSI
JetBackup
Linux
Litespeed
MySQL
NGINX
Oracle
Reduxio
Security
SSL
Uncategorized
VMware
Wordpress
XEN

Tags

apache aspx backup bash CentOS cloudlinux cPanel CXS Emails freetds google htaccess IMAP InnoDB iscsi JetBackup Libmodsecurity litespeed modsec modsecurity mssql MySQL netapp nginx odbc Oracle php php.ini phpselector rsync ssh ssmtp systemd threads VMFS WHM Wordpress xenserver

Popular Posts

  • Convert JetBackup to cPanel structure October 6, 2022
  • How To Install & Configure a Galera Cluster with MariaDB on Centos 7 February 6, 2018
  • Allow a cPanel server to run a VHOST from multiple IP addresses April 3, 2018
  • rsync without prompting for password October 10, 2022

Recent Posts

  • Understanding Why More Threads Can Sometimes Slow Down Performance October 9, 2024
  • Set up a new systemd service May 18, 2024
  • Bash Arrays November 7, 2023
  • rsync without prompting for password October 10, 2022

Recent Comments

  • Sven on rsync without prompting for password
  • TheLazyAdmin on rsync without prompting for password
  • Sven on rsync without prompting for password
  • TheLazyAdmin on Convert JetBackup to cPanel structure
  • Chris on Convert JetBackup to cPanel structure
Privacy Policy • Contact