Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deleting file created from mysql

I executed the query in mysql as

select * into outfile "/tmp/results.out" from table_x;

which in-turn wrote all the records in that table to the file in /tmp directory. The file was created with the following permissions.

-rw-rw-rw- 1 mysql mysql 6.6K Nov 14 10:14 /tmp/results.out

I know that it is not possible to delete this file from my login. But I tried removing this from MySQL, but I get the following error message:

mysql> system rm /tmp/results.out
rm: cannot remove `/tmp/results.out': Operation not permitted

PS: I do not have root permissions.

like image 442
Alagappan Ramu Avatar asked Nov 14 '12 04:11

Alagappan Ramu


People also ask

Is deletion possible in MySQL?

The Delete query in MySQL can delete more than one row from a table in a single query. This proves to be advantages when removing large numbers of rows from a database table. Once a Delete row in MySQL row has been deleted, it cannot be recovered.

Why delete is not working in MySQL?

Solution. By default, MySQL workbench is started in safe mode, and can't update or delete, without a “WHERE” condition, see the error message. To fix it, in menu, selects “Edit” -> “Preferences” -> “SQL Queries”, uncheck the “Safe Updates” checkbox. Done, try reconnect and issue the delete command again.


1 Answers

The file's owner group is mysql. Please use the id command to find out another user of that group and try deleting it. It appears that the user ID you are using to delete the file may not have write access on tmp directory.

Are you able to truncate the contents of the file? Please do this only if you don't want the results.out file in /tmp/

echo " " > /tmp/results.out
like image 140
Rishabh Sagar Avatar answered Oct 02 '22 05:10

Rishabh Sagar