mysqldump problems with restore error: 'Please DISCARD the tablespace before IMPORT'

前端 未结 4 1532
灰色年华
灰色年华 2020-12-14 07:40

I run a daily backup mysqldump backup of the production database (mysql version 5.1.66):

mysqldump --user=username --password=secret -C -e --create-options -         


        
相关标签:
4条回答
  • 2020-12-14 08:14

    Sounds like you have a tablename.ibd but no tablename.frm.

    To check:

    1. cd to your mysql data directory then the database name.
      cd /var/lib/mysql/database_name
    2. Search for the table name that is giving the error.

      ls tablename.*

      You should see two files:

      tablename.ibd
      tablename.frm
      

      But I'm guessing you don't and only see

      tablename.ibd

    To fix you have a few options:

    1. Add the follow to mysqldump, which will cause the database to be dropped, cleaning up data directory, before restore.
      --add-drop-database
    2. Copy the tablename.frm from prod over to dev and then issue a delete table statement.

    Also:

    • No need to use net_buffer_length=5000 when you're dumping to a file on localhost.
    • Other backup solutions - Percona Xtrabackup
    0 讨论(0)
  • 2020-12-14 08:14

    I also encountered that problem while dropping a schema and creating it again. I overcome this issue by going C:\ProgramData\MySQL\MySQL Server 5.6\data\my_database_name and deleting the tables which remained from the previous database creation. You can also delete the entire database, if you wish.

    0 讨论(0)
  • 2020-12-14 08:16

    I found the easiest way to skip this problem was to manually edit phpmyadmin database dump and edit/change the table that had problems to something else than INNODB. I changed the problem table to ENGINE=MyISAM and voila. Import worked.

    CREATE TABLE IF NOT EXISTS `home3_acymailing_tag` (
        `tagid` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
        `name` varchar(250) NOT NULL,
        `userid` int(10) unsigned DEFAULT NULL,
        PRIMARY KEY (`tagid`),
        KEY `useridindex` (`userid`)
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
    
    0 讨论(0)
  • 2020-12-14 08:25

    if you are using XAMPP then first ("stop") MySQL Then go to C:\xampp\mysql\data\dnb where in my case dnb is my database name folder. so then open it and delete .ibd file hence you can only delete it when you already stop MYsql . then go to phpmyadmin 1 click on phpmyadmin . 2 click on databases that appear below (server.127.0.0.1 in your case my be change) 3 then check your database which you want to drop,and click on drop. 4 then you can create database with same name and import your database successfully .here you can see how you drop database from phpmyadmin

    0 讨论(0)
提交回复
热议问题