NevadaSam Posted September 28, 2006 Share Posted September 28, 2006 I want to dump the contents of a table from my database into a text file. My logon (host, username, password) are all correct. And my query syntax is good. [quote]SELECT * INTO OUTFILE 'books.txt'FIELDS TERMINATED BY '|'FROM books[/quote]But I get this error when I run it:[code]Error 1045: Access denied for user 'user'@'localhost' (using password: YES)[/code]I was hoping that it would write the txt file to the directory from where I was running the query. But I am thinking that it is trying to write it to the MySQL server which, of course, I don't have permission to do.How can I dump this?Sam Link to comment https://forums.phpfreaks.com/topic/22436-output-db-to-text-file/ Share on other sites More sharing options...
fenway Posted September 29, 2006 Share Posted September 29, 2006 I'm pretty sure you need the LOCAL modifier so that you're not writing to the server directory. Link to comment https://forums.phpfreaks.com/topic/22436-output-db-to-text-file/#findComment-100644 Share on other sites More sharing options...
NevadaSam Posted September 29, 2006 Author Share Posted September 29, 2006 I tried many different variations of the file location modifier ("/public_html/save.txt" and more) but I believe it is a privilege issue. I learn more about the SELECT INTO OUTFILE command since my last post. It seems that the FILE privilege is normally not granted because of security reasons. This from my text: [quote][b][u]The FILE privilege[/u].[/b] This enables a user to access files on the server machine with the same privileges as the MySQL server process. This privilege is useful for executing the LOAD DATA INFILE and SELECT INTO OUTFILE statements that read from and write to server-side files. This privilege, however, can be abused as a backdoor around operating systems security and thus should be granted sparingly.[/quote]I can do the LOAD DATA INFILE on most hosting services. So when I learn more about PHP I will write a script that will SELECT all the data from a table and then I will output it to a text file that way. Thanks for taking time to read my posts.Sam Link to comment https://forums.phpfreaks.com/topic/22436-output-db-to-text-file/#findComment-101191 Share on other sites More sharing options...
fenway Posted September 30, 2006 Share Posted September 30, 2006 I didn't realize that the file had to be written on the server host, and hence would require FILE permissions that are generally not granted for security reasons. But yes, you might as well just roll-your-own export script. Link to comment https://forums.phpfreaks.com/topic/22436-output-db-to-text-file/#findComment-101418 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.