Syntax\n------\n\nSELECT ... INTO DUMPFILE 'file_path'\n\nDescription\n-----------\n\nSELECT ... INTO DUMPFILE is a SELECT clause which writes the resultset into a single unformatted row, without any separators, in a file. The results will not be returned to the client.\n\n_file_path_ can be an absolute path, or a relative path starting from the data directory. It can only be specified as a string literal, not as a variable. However, the statement can be dynamically composed and executed as a prepared statement to work around this limitation.\n\nThis statement is binary-safe and so is particularly useful for writing BLOB values to file. It can be used, for example, to copy an image or an audio document from the database to a file.\n\nThe file must not exist. It cannot be overwritten. A user needs the FILE privilege to run this statement. Also, MariaDB needs permission to write files in the specified location. If the secure_file_priv system variable is set to a non-empty directory name, the file can only be written to that directory.\n\nThe character_set_filesystem system variable has controlled interpretation of file names that are given as literal strings.\n\nThe character_set_filesystem system variable does not have controlled interpretation of file names that are given as literal strings.\n\nExamples\n--------\n\nSELECT _utf8'Hello world!' INTO DUMPFILE '/tmp/world';\n\nSELECT LOAD_FILE('/tmp/world') AS world;\n+--------------+\n| world        |\n+--------------+\n| Hello world! |\n+--------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/select-into-dumpfile