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

前端 未结 4 1539
灰色年华
灰色年华 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

提交回复
热议问题