Return to Snippet

Revision: 3779
at September 13, 2007 13:11 by micmath


Updated Code
# export structure only (no data) as sql
mysqldump -u root -pthePasssword --no-data theDbName > mydata.sql

# export with data as sql
mysqldump -u root -pthePasssword --default-character-set=latin1 --skip-set-charset theDbName > mydata.sql

# import sql
mysql -u root -pthePasssword -D theDbName < mydata.sql

# export data as a comma separated values document
SELECT * INTO OUTFILE '/tmp/mydata.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' FROM mydata;

# import data from a comma separated values document
LOAD DATA LOCAL INFILE '/tmp/mydata.csv' INTO TABLE mydata FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n';

Revision: 3778
at September 13, 2007 13:10 by micmath


Updated Code
# export structure only (no data) as sql
mysqldump -u root -pthePasssword --no-data theDbName > mydata.sql

# export with  data as sql
mysqldump -u root -pthePasssword --default-character-set=latin1 --skip-set-charset theDbName > mydata.sql

# import sql
mysql -u root -pthePasssword -D theDbName < mydata.sql

# export data as a comma separated values document
SELECT * INTO OUTFILE '/tmp/mydata.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' FROM mydata;

# import data from a comma separated values document
LOAD DATA LOCAL INFILE '/tmp/mydata.csv' INTO TABLE mydata FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n';

Revision: 3777
at September 13, 2007 13:09 by micmath


Updated Code
# export structure only (no data) as sql
mysqldump -u root -pthePasssword --no-data --default-character-set=latin1 --skip-set-charset theDbName > mydata.sql

# import sql
mysql -u root -pthePasssword -D theDbName < mydata.sql

# export data as a comma separated values document
SELECT * INTO OUTFILE '/tmp/mydata.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' FROM mydata;

# import data from a comma separated values document
LOAD DATA LOCAL INFILE '/tmp/mydata.csv' INTO TABLE mydata FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n';

Revision: 3776
at September 13, 2007 12:24 by micmath


Updated Code
# export structure only (no data) as sql
mysqldump -u root -pthePasssword --no-data theDbName > mydata.sql

# import sql
mysql -u root -pthePasssword -D theDbName < mydata.sql

# export data as a comma separated values document
SELECT * INTO OUTFILE '/tmp/mydata.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' FROM mydata;

# import data from a comma separated values document
LOAD DATA LOCAL INFILE '/tmp/mydata.csv' INTO TABLE mydata FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n';

Revision: 3775
at September 13, 2007 12:18 by micmath


Updated Code
# export structure only (no data) as sql
mysqldump -u root -pthePasssword --no-data theDbName > theDbName.sql

# import sql
mysql -u root -pthePasssword < theDbName.sql

# export data as a comma separated values document
SELECT * INTO OUTFILE '/tmp/mydata.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' FROM mydata;

# import data from a comma separated values document
LOAD DATA LOCAL INFILE '/tmp/mydata.csv' INTO TABLE mydata FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n';

Revision: 3774
at September 13, 2007 11:40 by micmath


Initial Code
# export structure only (no data)
mysqldump -u root -pthePasssword --no-data theDbName > theDbName.sql

# export data as a comma separated values document
SELECT * INTO OUTFILE '/tmp/mydata.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' FROM mydata;

# import data from a comma separated values document
LOAD DATA LOCAL INFILE '/tmp/mydata.csv' INTO TABLE mydata FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n';

Initial URL

                                

Initial Description

                                

Initial Title
Export and import from MySQL

Initial Tags
mysql

Initial Language
SQL