Posts

Showing posts from July, 2020

Export single table MySQL

Using OUTFILE will output a table to CSV but gives an access denied error for non root users. SELECT * FROM orders WHERE foo = 'bar' INTO OUTFILE '/var/lib/mysql-files/orders.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n' ;   A quicker way than granting access etc is to simply dump the table from ssh into an sql file, and convert the data oneself using vi and regex.  mysqldump db_name table_name > table_name . sql