Category Archives: MySQL

Mysql create user + password

CREATE USER 'myuser'@'localhost' IDENTIFIED BY '1ed0d4f451266a8e07f3c0c3b54a8c1b';
GRANT ALL ON mydb.* TO 'myuser'@'localhost';

To remove

REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'myuser'@'localhost';
DROP USER 'myuser'@'localhost';

MYSQL to TSV / TAB / CSV

TSV (much easier to use in practice due to lack of need to escape)

SELECT *
FROM pageviews
INTO OUTFILE '/tmp/pageviews.tsv'
FIELDS TERMINATED BY '\t'
LINES TERMINATED BY '\n'

CSV (if you must)

SELECT *
FROM pageviews
INTO OUTFILE '/tmp/pageviews.csv'
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n';




Note: won’t include column names. There’s no easy way to do this from within mysql, though can be done from the command line.