Export data from a table
I have a table with 45 millions from a mysql DB, i want to export those data in a .csv format, what is best way to do without affecting existing performance of other t开发者_运维技巧ables (when this operation is performed)?
Thanks.
Ok i figured it out,
to export ->select * into outfile 'c:/tmp/outfile.txt' fields terminated by ',' from tablename;
To Import
LOAD DATA LOCAL INFILE 'c:/tmp/outfile.txt' INTO TABLE newtablename FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n';
select * from table_name into outfile '/tmp/output_file.csv';
However, you may face a problem "Can't create/write to file", then you can do these following code.
USE mysql;
UPDATE user SET File_priv = 'Y' WHERE User = 'db_user';
FLUSH PRIVILEGES;
Then, you can export table.
精彩评论