birmingham@ic.fbi.gov , phoenix@ic.fbi.gov , fbise@leo.gov
NickSoft Linux Cookbook Index NickSoft Linux Cookbook
Quick howto's, Real live examples.
 
 FAQFAQ   SearchSearch   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Dump database to text file and then restore it

 
Post new topic   Reply to topic    NickSoft Linux Cookbook Index -> MySQL
View previous topic :: View next topic  
Author Message
NickSoft
Site Admin


Joined: 13 Nov 2006
Posts: 22

PostPosted: Mon Nov 13, 2006 3:03 pm    Post subject: Dump database to text file and then restore it Reply with quote

mysqldump command dumps databases/tables to standart output. You can use pipe redirect to save it to file:
Code:
mysqldump [options] >dump.sql


When you dump a database there are some options of mysqladmin you need to understand:
--skip-comments - Use this option if you want make a smaller file
--compatible - if you export database from higher version to lower you will need this option. Possible values are:
    --compatible=mysql323
    --compatible=mysql40
    --compatible=mysql323

--disable-keys - this will speed up import process
--add-drop-table - if you make backups you can assume that when you restore it, tables will be created and they need to be dropped. This option does it.
--quote-names - if you use reserved words as comumn or table names this will prevent errors during import.


How to dump a table(s):
Code:
mysqldump [i]<db_name>[/i] [i]<table1>[/i] [i]<table2>[/i] ...

How to dump a database:
Code:
mysqldump [i]<db_name>[/i]

How to dump a more than one database:
Code:
mysqldump [u]--databases[/u] [i]<db_name1>[/i] [i]<db_name2>[/i] ...

How to dump all databases:
Code:
mysqldump --all-databases
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    NickSoft Linux Cookbook Index -> MySQL All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




MLDb.org Magic Eight Ball Croler Web Search Croler Web Directory Bianca Ryan MyBestMatch.net Microlab.info

Powered by 220V