Mysqldump - How to recover one table from this file?

I need to restore only one table in my database.

I have a file .sqlthat contains all the information I need for one table, and the rest will overwrite important information for other tables.

Instead of using the here solution - with a tool I had never heard of, I thought it was more confident to do it manually.

Unfortunately, MySqlDump generated the GIANT insert line too long to insert mysql into the command line ...

What should I do?

Should I use sed as described above?

Or can I copy the commands for this particular table from mysqldump.sqlto a new file .sql, and then call:

mysql -u root -p -h localhost < copyPasteFile.sql
+4
source share
3 answers

u can try it

mysql -u root -p databasename -h localhost < copyPasteFile.sql 
+2
source

I'm not sure if this is the best way, but I just unwind a new circuit and restore the backup to it. Dump the data I need and import it into the production database.

I use the MYSQL desktop, which simplifies the work, but the steps below can be reproduced on the command line

  • Create a new MYSQL schema
  • Import offline backup
  • Set the "Target Schema" for the new empty database (.sql Dump should not contain the schema creation code)
  • Backup recovery
  • Dump table in csv and import it into the production database

, , :

mysql -u <user name> -p <password> <database name> < sqlfilename.sql

0
mysql -uuser -ppassword -e "create database temporary"

mysql -uuser -ppassword temporary < copyPasteFile.sql

mysqldump -uuser -ppassword temporary yourtable > onlythattable.sql

mysql -uuser -ppassword therealdb < onlythattable.sql

mysql -uuser -ppassword -e "drop database temporary"

make sure copyPasteFile.sql does not have "use somedatabase"; if it was exported using phpmyadmin, it probably has this; if it was exported using mysqldump, it will not.

0
source

All Articles