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
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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.