Is there a way to covert or export an entire MySQL

2019-07-04 21:39发布

I am working with a large database 1.5 gig in size and hundreds of tables / fields. I need to convert all tables into CSV files. PhpMyAdmin does not do this easily / times out.

I would rather use a shell / mysql command or a script to get the data out and into CSV.

Note:

I am looking to export ALL tables of the database - in 1 shot. I can not produce an export command for every single table individually.

3条回答
相关推荐>>
2楼-- · 2019-07-04 21:57

You can use mysqldump:

The mysqldump command can also generate output in CSV, other delimited text, or XML format.

In particular, look at the following arguments:

查看更多
女痞
3楼-- · 2019-07-04 22:00

You will need to do this table by table, see below.

SELECT *
INTO OUTFILE '/tmp/products.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '\n'
FROM products

Note that the directory must be writable by the MySQL database server. If it's not, you'll get an error message like this:

#1 - Can't create/write to file '/tmp/products.csv' (Errcode: 13)

Also note that it will not overwrite the file if it already exists, instead showing this error message:

#1086 - File '/tmp/products.csv' already exists

Source: http://www.electrictoolbox.com/mysql-export-data-csv/

查看更多
欢心
4楼-- · 2019-07-04 22:05

Information about the software : sql2csv

Download link exe : http://www.convert-in.com/demos/sql2csv.exe

This is best option I found around for windows. With the software we can connect to local and remote DB server and select schema. In one shot we can extract all tables data into Valid CSV files.

Features :

enter image description here

查看更多
登录 后发表回答