How to create a file in query with read and write permission for all users in mysql 8



  • When I run this query on mysql 5.7:

    SELECT CURDATE() INTO OUTFILE '/var/lib/mysql-files/test.csv';
    

    It creates test.csv with the following permissions:

    -rw-rw-rw- 1 mysql mysql        11 Mar 18 04:27 test.csv
    

    But when I create the same file in mysql 8.0 it creates file with the following permissions:

    -rw-r----- 1 mysql mysql    11 Mar 18 09:54 test.csv
    

    How would I allow mysql 8 to create file with the same permissions it created with mysql 5.7 ? The reason being I need to read and write to that generated file later in my application.


  • QA Engineer

    From the Changelog:

    ----- 2019-07-22 8.0.17 General Availability -- -- -----

    The umask for files created using SELECT ... INTO OUTFILE or SELECT ... INTO DUMPFILE was changed from 0666 to 0640. The https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_load-file function no longer requires files to be world-readable, just readable by the server. (Bug #24513720)

    (Unfortunately, Oracle does not let us see that bug report.)




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2