About SELECT INTO OUTFILE
The SELECT INTO OUTFILE statement writes the results of a query to a file. You can also specify custom column and row terminators to format the output.Support for SELECT INTO OUTFILE
SELECT INTO OUTFILE statements are supported on all unmanaged hosting packages, where you have complete control over the environment, including MySQL user privileges and configuration. Shared and reseller hosting packages, however, do not allow you to run SELECT INTO OUTFILE statements. For security reasons, users are not granted the FILE privilege, which is necessary to run SELECT INTO OUTFILE statements.Alternative to SELECT INTO OUTFILE
If your hosting package does not allow you to run SELECT INTO OUTFILE statements, you can still create files based on MySQL queries. To do this, simply redirect the SQL query output to a file from the command line. The following example demonstrates how to do this:- sql_query: This is the actual SQL query, such as “SELECT * FROM employees;”.
- mysql_username: This is the MySQL username for the database that you want to access.
- mysql_password: This is the password for the MySQL username you are using above.
- mysql_database: This is the name of the MySQL database that you want to access.
- username: This is your hosting.com account username.