Rather than using mysqldump, which outputs data in a format primarily designed for MySQL, you can utilize alternative methods to create universal CSV backups.
To generate tab-separated (TSV) files compatible with Excel and other spreadsheet software, employ the -B option in MySQL. This method allows for easy data importation into external applications:
% echo 'SELECT * FROM table' | mysql -B -uxxx -pyyy database
Alternatively, if you have direct access to the server's file system, consider using SELECT INTO OUTFILE. This method generates true CSV files:
SELECT * INTO OUTFILE 'table.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' FROM table
By using these approaches, you can createplaintext (CSV) backups from the command line, providing flexibility and compatibility with various platforms.
The above is the detailed content of How Can I Dump MySQL Databases to Plaintext (CSV) Backups?. For more information, please follow other related articles on the PHP Chinese website!