Export and import from MySQL


/ Published in: SQL
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.