简体   繁体   中英

MySQL SELECT .... INTO OUTFILE not working

I have used the following code to backup a MySQL table:

$query = "SELECT * INTO OUTFILE '/tmp/mytableDB.txt' FROM mytable";

It does not appear to be working.

The following error checking code was used:

$result = mysql_query($query);
if ($result)
    echo 'Database was successfully backed up';
else
    echo 'Not backed up';

but the documentation was not clear as to whether or not a return value is generated.

The message 'Not backed up' was echoed.

The database is accessed via WampServer on a Windows machine.

The manual located at:

http://dev.mysql.com/doc/refman/5.0/en/select-into.html

does not appear to cover this issue.

Has anybody come across this problem & found a solution while using WampServer?

Be sure the database user has FILE permission.

GRANT FILE ON db.* TO user; 

A quote from the manual you posted:

The file is created on the server host, so you must have the FILE privilege to use this syntax.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM