Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Wanna export a joined result?
- SELECT a.id, a.name, b.name
- FROM tableA a
- JOIN tableB b ON a.id = b.rel_id
- WHERE a.deleted=0 and b.deleted=0
- ORDER BY a.name, b.nane
- INTO OUTFILE '/var/lib/mysql-files/xxxx.csv'
- FIELDS TERMINATED BY ','
- ENCLOSED BY '"'
- LINES TERMINATED BY '\n';
- -- Trouble shooting #1
- -- User needs to have the FILE grant
- mysql> show grants for <user>
- -- If it's missing, then grant it
- mysql> GRANT FILE ON *.* TO
- -- Trouble shooting #2
- -- Output path strict?
- mysql> SHOW VARIABLES LIKE "secure_file_priv";
- +------------------+-----------------------+
- | Variable_name | Value |
- +------------------+-----------------------+
- | secure_file_priv | /var/lib/mysql-files/ |
- +------------------+-----------------------+
Add Comment
Please, Sign In to add comment