MySQL – mysqldump Writes to /tmp and /var/tmp Only

mysqldump

I have various mysql databases on different servers and at different versions. I'm using the same mysqldump command across Linux versions without issue except for this new Red Hat 7.6 server.

Command:

mysqldump –tab=/var/tmp/mysql/mysql.20190808/wikidb –opt –user=root –password=[password] wikidb

Prior to the mysqldump command:

mkdir -p /var/tmp/mysql/mysql.20190808/wikidb
chown -R mysql:mysql /var/tmp/mysql/mysql.20190808
chmod 777 /var/tmp/mysql/mysql.20190808

This is all scripted so no chance for a typo.

On all the older servers, and especially the older wiki servers this server is replacing, the command works successfully. I get a list of all the tables and .txt files for the database in the directory.

On the new server, I get the very first table, back_archive.sql, and then an error:

mysqldump: Got error: 1: "Can't create/write to file '/var/tmp/mysql/mysql.20190808/wikidb/back_archive.txt' (Errcode: 2)" when executing 'SELECT INTO OUTFILE'

I've tried various permissions including 1777 to give it a sticky bit just in case and it still fails. Ownership is confirmed as mysql:mysql and the database owner is mysql.

I'd done quite a bit of searching and reading of the man pages and everyone pretty much blames it on ownership or directory permissions but as noted above, I believe I've done it correctly, especially since it's a script and is working on every other server.

I will note this is my first master/master replication server. I didn't find anything specific regarding this sort of configuration but I thought I'd mention it.

Best Answer

[Lots of] Other things can get in the way.

SELinux can cause all sorts of problems, making really basic things fail for no apparent [or announced] reason.

ACL's in the file system can cause confusion, sneakily "tweaking" permissions without you realising it.

Is it possible that the MySQL configuration is different?
These days, a clean install of MySQL might well come with --secure-file-priv turned on. If that doesn't match where you're trying to put the file, you'll hit another wall.

Regards, Phill W.