I need to dump data from one table in my MySQL 8 database and reimport into a different table which already exists and has it’s schema. The schema is identical between the two such as columns, how can I achieve this, i just need the row imsert statements from mysqldump without locking and create info
My export:
mysqldump -u root -p --no-create-info icicle_db users > users_existing.sql
I’ve tried to import
mysqldump -u root -p --no-create-info icicle_db users_new < users_existing.sql
But users_existing.sql
contains references to the old table, i just need insert data not other schema. I’m trying it on a small table before trying a table with millions of rows. What am i missing?
2
Answers
This seems to have been asked here:
How can I import a mysql dump?
Quick answer:
You need to replace the table name in
users_existing.sql
file.This can be done using
sed
command.Then proceed with the restore