views:

15

answers:

1

When I output a whole table into an output file named 'Arshan.txt' this command works well but I can not access the output file created. When I access /usr/local/mysql/data it says permission denied. Any help will be appreciated. Thanks in advance.

A: 

You'll need to access the file using the same account the MySQL process is running under. If you're an administrator on the machine you can also use sudo to execute any command with superuser privileges. For example:

sudo cp /usr/local/mysql/data/Arshan.txt ~foo/Arshan.txt
sudo chown foo ~foo/Arshan.txt
VoteyDisciple
When I enter this command it says no such file or directory. thats strange. I used the following mysql statement
SELECT * From CLA INTO OUTFILE 'Arshan.txt'
If it says the file doesn't exist even when using `sudo`, the file definitely doesn't exist. Perhaps you saved it in a different path than you think you did, or perhaps the `SELECT ... INTO OUTFILE` query didn't work.
VoteyDisciple
Thats what I thought too but when I repeat the above statement in MySQL it says 'Arshan.txt' already exists :(
In that case it's a question of the path you're using. Changing the path to something outside of `/usr/local/mysql/` is wise anyway. Why risk mixing up generated output with proper database files.
VoteyDisciple
thank you so much for your replies. I tried changing the path too but it says 'Cant create/write to file.
Then make sure MySQL's account can write wherever you're trying to have it write.
VoteyDisciple
The "SELECT ... INTO OUTFILE" statement saves it into the specific directory of the selected database, not the top-level directory. So it's not "/usr/local/mysql/data/Arshan.txt". It's "/usr/local/mysql/data/your_database_name/Arshan.txt". Besides the slight difference in paths, VoteyDisciple's commands should work.
Ben Lee
Although, I would opt for a "sudo mv ..." instead of a "sudo cp ..." to avoid leaving stale files around.
Ben Lee
Great worked for me :) Thank you all