Posted By

micmath on 09/13/07


Tagged

mysql


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

basicmagic
uisluu
Leech
mgerdt


Export and import from MySQL


 / Published in: SQL
 

  1. # export structure only (no data) as sql
  2. mysqldump -u root -pthePasssword --no-data theDbName > mydata.sql
  3.  
  4. # export with data as sql
  5. mysqldump -u root -pthePasssword --default-character-set=latin1 --skip-set-charset theDbName > mydata.sql
  6.  
  7. # import sql
  8. mysql -u root -pthePasssword -D theDbName < mydata.sql
  9.  
  10. # export data as a comma separated values document
  11. SELECT * INTO OUTFILE '/tmp/mydata.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' FROM mydata;
  12.  
  13. # import data from a comma separated values document
  14. LOAD DATA LOCAL INFILE '/tmp/mydata.csv' INTO TABLE mydata FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n';

Report this snippet  

You need to login to post a comment.