How do I export from MYSQL to CSV in mariadb on Centos 7?


If you can cope with table-at-a-time, and your data is not binary, use the -B option to the mysqlcommand. With this option it'll generate TSV (tab separated) files which can import into Excel, etc, quite easily:

% echo 'SELECT * FROM table'| mysql -B -uxxx -pyyy database

Alternatively, if you've got direct access to the server's file system, use SELECT INTO OUTFILE which can generate real CSV files:

SELECT*INTO OUTFILE 'table.csv'
    FIELDS TERMINATED BY',' OPTIONALLY ENCLOSED BY'"'
    LINES TERMINATED BY'\n'FROMtable

mysql -uvpopmail vpopmail -pPassW0rd  -e " select pw_name,pw_gecos,pw_clear_passwd from test_com "  | sed 's/\t/","/g;s/^/"/;s/$/"/' > migration_list.csv

Date: 30th August, 2016 Written by Satya Comment count: 0

Google map:

About The Author

Satya

<p>satya maharjan</p>
Want to reach this author? |
Share It: