开发者

Are any permissions required to backup a mysql table through php script

开发者 https://www.devze.com 2023-03-04 22:48 出处:网络
I want to take back up of mysql database table in sql file through php script. I am using below code. mysql_query(\"SELECT * INTO OUTFILE \'backupfile.sql\' FROM tablename\");

I want to take back up of mysql database table in sql file through php script.

I am using below code.

mysql_query("SELECT * INTO OUTFILE 'backupfile.sql' FROM tablename");

It gives me following error :

Access denied for user 'username'@'localhost' (using password: YES)

The 'username' has these permissions :

SELECT, INSERT, UPDATE, DELETE, INDEX, CREATE, ALTER, DROP, LOCK TABLES, REFERENCES, CREATE ROUTINE, CREATE TEMPORARY TABLES

I just want to know is there any extra permission required to execute select * into outfile and same for the LOAD DATA INFILE开发者_运维问答 'filename' INTO TABLE tablename.


You need the FILE privilege to use SELECT ... INTO OUTFILE, since the command will create a file on the MySQL server host.

I also think your query is wrong. This should be the right order according to the manual:

SELECT * FROM tablename INTO OUTFILE 'backupfile.sql';
0

精彩评论

暂无评论...
验证码 换一张
取 消