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: