DelphiFAQ Home Search:

Exporting and importing between 2 mysql databases


commentsThis article has not been rated yet. After reading, feel free to leave comments and rate it.


I need to restore a table from a mysql backup. How can I do that?


Follow these steps:
  1. Create a second database, here called olddb
  2. Assuming you have a SQL dump at hand, pass it to mysql. The backup script is called backup.sql below
  3. Export the table to a local file (here: /Content/tmp/data.txt)
  4. Leave this database and go back to your regular db
  5. Do a LOAD DATA INFILE to restore your data (maybe empty that table first)

mysqladmin -uroot -pPASS create olddb

mysql -uroot -pPASS olddb <backup.sql

mysql -uroot -pPASS olddb
select * from MYTABLE into outfile '/Content/tmp/data.txt';

mysql -uroot -pPASS
LOAD DATA INFILE '/Content/tmp/data.txt' 

Content-type: text/html


2012-11-12, 03:53:19
coach001 from United States  



NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: