mysqldump problems with restore error: 'Please DISCARD the tablespace before IMPORT'
Sounds like you have a tablename.ibd but no tablename.frm.
To check:
- cd to your mysql data directory then the database name.
cd /var/lib/mysql/database_name
Search for the table name that is giving the error.
ls tablename.*
You should see two files:
tablename.ibd
tablename.frmBut I'm guessing you don't and only see
tablename.ibd
To fix you have a few options:
- Add the follow to mysqldump, which will cause the database to be dropped, cleaning up data directory, before restore.
--add-drop-database
- 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
Oracle SQL DROP CREATE TABLESPACE error
My guess would be that the file is already part of the database, but part of a tablespace named something other than temp.
What do you get from the following query:
select tablespace_name from dba_data_files where file_name = 'C:/Oracle/oradata/orcl/temp.dbf'
union all
select tablespace_name from dba_temp_files where file_name = 'C:/Oracle/oradata/orcl/temp.dbf';
ORACLE Database | remove tablespace with missing datafile
You can follow the steps given here in this Oracle forum:
Follow the below steps : -
1) Shutdown abort
2) sqlplus sys/xxx as sysdba
3) Alter database mount
4) alter database datafile '' offline drop;
5) Alter database open
MYSQL Error at restoring database: Please DISCARD the tablespace before IMPORT
I deleted the database using the following:
cd data; sudo rm -rf COMMERCE_DB_622;
However, the important thing is always in the beginning use the regular remove SQL:
DROP DATABASE COMMERCE_DB_622
If the "DROP DATABASE" SQL results in error then one can remove the data using the remove directory command.
mysqldump add TABLESPACE definition that fails during import
After some research and tests, this is what my understanding is.
When databases are created with tablespaces, mysqldump does not include the tablespace definitions. There is no option with mysqldump to ignore tablespace references. So, I had two options after taking dump.
1. Edit the dump manually and remove the references to tablespace.
2. Create the tablespace before importing the dump.
I had a luxury to import into a server that was running as container. So, mysql listed all the tablespaces that were not available (After such error reported, I could throw away the mysql container and start another one - to feel that the server is fresh). Since I knew all the tablespaces, I went with the second option and also thought that editing the dump created by tool (mysqldump) is not a good idea.
Used the following statement to create tablespace
create tablespace <tablespace-name> add datafile 'tablespace-name.ibd'
This approach worked for me.
Related Topics
Er_Access_Denied_Error: Access Denied for User ''@'Localhost' (Using Password: No)
Select Only Rows With Max Date
Inserting Date Value into Date Field Using Laravel
Select to Get Rows Based on Minimum Value of a Column
How to in a Query Calculate the Sum of the Union
Localhost/Phpmyadmin Giving Page Not Found Error
Mysql - Get All Records That Have More Than 1 Record for the Same Id
Sql Get Parent Where Children Have Specific Values
Oracle Sql, Concatenate Multiple Columns + Add Text
Postgresql Delete Multiple Rows from Multiple Tables
How to Insert Null into the Datetime Coulmn Instead 1900-01-01 00:00:00.000 in SQL Server
How to Execute a Stored Procedure Once for Each Row Returned by Query
How to Calculate Age (In Years) Based on Date of Birth and Getdate()
Retrieve Varbinary Value as Base64 in Mssql
Disable Secure Priv for Data Loading on MySQL
Query City Names Starting and Ending With Vowels
How to Use SQL Like Condition With Multiple Values in Postgresql