Guest User

Untitled

a guest
Jul 20th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. -- Wanna export a joined result?
  2. SELECT a.id, a.name, b.name
  3. FROM tableA a
  4. JOIN tableB b ON a.id = b.rel_id
  5. WHERE a.deleted=0 and b.deleted=0
  6. ORDER BY a.name, b.nane
  7. INTO OUTFILE '/var/lib/mysql-files/xxxx.csv'
  8. FIELDS TERMINATED BY ','
  9. ENCLOSED BY '"'
  10. LINES TERMINATED BY '\n';
  11.  
  12.  
  13. -- Trouble shooting #1
  14. -- User needs to have the FILE grant
  15. mysql> show grants for <user>
  16. -- If it's missing, then grant it
  17. mysql> GRANT FILE ON *.* TO
  18.  
  19. -- Trouble shooting #2
  20. -- Output path strict?
  21. mysql> SHOW VARIABLES LIKE "secure_file_priv";
  22. +------------------+-----------------------+
  23. | Variable_name | Value |
  24. +------------------+-----------------------+
  25. | secure_file_priv | /var/lib/mysql-files/ |
  26. +------------------+-----------------------+
Add Comment
Please, Sign In to add comment