lundi 1 décembre 2014

writing mysql output to file in CentOS 7


I am trying to run the following command from inside the mysql command line client in the CentOS terminal:



SELECT Concat('TRUNCATE TABLE ',table_schema,'.',TABLE_NAME, ';')
FROM INFORMATION_SCHEMA.TABLES where table_schema in ('justatest')
INTO OUTFILE '/home/user/tmp/truncate.sql';


The result is this error:



ERROR 1 (HY000): Can't create/write to file '/home/user/tmp/truncate.sql'
(Errcode: 13 - Permission denied)


I then opened a new terminal, typed su -, gave the password, and then typed the following commands:



chown root:root /home/user/tmp
chmod 1777 /home/user/tmp


But I still get the same error when I run the original SQL code at top above.


EDIT:


I also get the same error when I try:



chown username:username /home/user/tmp
chmod 1777 /home/user/tmp


and the same error message when I try:



chown mysql:mysql /home/user/tmp
chmod 1777 /home/user/tmp


How can I resolve this error?



Aucun commentaire:

Enregistrer un commentaire