Jump to content

Output DB to text file


NevadaSam

Recommended Posts

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


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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.