Home > Blockchain >  Ignore "nohup" warning not working for mysqldump
Ignore "nohup" warning not working for mysqldump

Time:11-23

I know there're tons similar question but somehow I can't get it right.

When run this command, my "dump.sql" produced desired result

mysqldump -uuser -ppassword --comments --single-transaction --quick mydb desired_table | gzip >dump.sql.gz

This is the first line of dump.sql

-- MySQL dump 10.13  Distrib 8.0.21, for Linux (x86_64)

But with this command:

nohup mysqldump -uuser -ppassword --comments --single-transaction --quick mydb desired_table | gzip >dump.sql.gz 2>/dev/null &

This is the first line of dump.sql:

mysqldump: [Warning] Using a password on the command line interface can be insecure.

Which will cause error when import the dump file. How? From what I understand, "2>" means redirect error. If I change to this command, nothing in the "dump.log":

nohup mysqldump -uuser -ppassword --comments --single-transaction --quick mydb desired_table | gzip >dump.sql.gz 2>dump.log &

CodePudding user response:

To redirect the stderr of the mysqldump command before sending it to gzip, do that before the pipe.

nohup mysqldump -uuser -ppassword --comments --single-transaction \
   --quick mydb desired_table 2>/dev/null | gzip >dump.sql.gz  &

This is not related to your stderr redirection question, but I would also recommend using an options file instead of putting user and password on the command line.

CodePudding user response:

It is not a good idea to circumvent a warning about a security problem by any means...

You should change the way to provide the password for the database connection. Look at these related question and answers.

  • Related