Suppress warning messages from MySQL in shell script but allow errors

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
6
down vote

favorite












My log files are getting dumped with following message while running shell scripts using some underlying MySQL commands.



Here is the message:




"Warning: Using a password on the command line interface can be insecure."




To stop these messages, I am using the following job definition.



Example:



run_wrapper.sh |grep -v "Warning: Using a password" > output.log 2>&1


This worked but the MySQL errors are not being logged to output.log.



If I change the definition like the following, then MySQL errors start appearing if any



run_wrapper.sh > output.log 2>&1


So the question is how to suppress the warning messages and also report SQL errors in log files using only the cron definition?







share|improve this question






















  • probably you should use run_wrapper.sh >> output.log 2>&1
    – Rahul
    Jul 5 '16 at 9:17






  • 1




    I'm not following. Where would you want error/warnings to go and where would you want output to go, and what would you want to throw away? What is generating the password warning and why do you have errors in the MySQL that you don't want to fix?
    – Kusalananda
    Jul 5 '16 at 9:38






  • 1




    mysql prints that warning when you use the -p option on the command line. Instead of fixing it (e.g. by creating a ~/.my.cnf with 600 perms) the OP wants to just ignore and discard the warning (and only that warning, not all of stderr)
    – cas
    Jul 5 '16 at 13:10















up vote
6
down vote

favorite












My log files are getting dumped with following message while running shell scripts using some underlying MySQL commands.



Here is the message:




"Warning: Using a password on the command line interface can be insecure."




To stop these messages, I am using the following job definition.



Example:



run_wrapper.sh |grep -v "Warning: Using a password" > output.log 2>&1


This worked but the MySQL errors are not being logged to output.log.



If I change the definition like the following, then MySQL errors start appearing if any



run_wrapper.sh > output.log 2>&1


So the question is how to suppress the warning messages and also report SQL errors in log files using only the cron definition?







share|improve this question






















  • probably you should use run_wrapper.sh >> output.log 2>&1
    – Rahul
    Jul 5 '16 at 9:17






  • 1




    I'm not following. Where would you want error/warnings to go and where would you want output to go, and what would you want to throw away? What is generating the password warning and why do you have errors in the MySQL that you don't want to fix?
    – Kusalananda
    Jul 5 '16 at 9:38






  • 1




    mysql prints that warning when you use the -p option on the command line. Instead of fixing it (e.g. by creating a ~/.my.cnf with 600 perms) the OP wants to just ignore and discard the warning (and only that warning, not all of stderr)
    – cas
    Jul 5 '16 at 13:10













up vote
6
down vote

favorite









up vote
6
down vote

favorite











My log files are getting dumped with following message while running shell scripts using some underlying MySQL commands.



Here is the message:




"Warning: Using a password on the command line interface can be insecure."




To stop these messages, I am using the following job definition.



Example:



run_wrapper.sh |grep -v "Warning: Using a password" > output.log 2>&1


This worked but the MySQL errors are not being logged to output.log.



If I change the definition like the following, then MySQL errors start appearing if any



run_wrapper.sh > output.log 2>&1


So the question is how to suppress the warning messages and also report SQL errors in log files using only the cron definition?







share|improve this question














My log files are getting dumped with following message while running shell scripts using some underlying MySQL commands.



Here is the message:




"Warning: Using a password on the command line interface can be insecure."




To stop these messages, I am using the following job definition.



Example:



run_wrapper.sh |grep -v "Warning: Using a password" > output.log 2>&1


This worked but the MySQL errors are not being logged to output.log.



If I change the definition like the following, then MySQL errors start appearing if any



run_wrapper.sh > output.log 2>&1


So the question is how to suppress the warning messages and also report SQL errors in log files using only the cron definition?









share|improve this question













share|improve this question




share|improve this question








edited Jul 9 '16 at 18:55









Jeff Schaller

31.2k846105




31.2k846105










asked Jul 5 '16 at 9:03









jagadish puvvada

31113




31113











  • probably you should use run_wrapper.sh >> output.log 2>&1
    – Rahul
    Jul 5 '16 at 9:17






  • 1




    I'm not following. Where would you want error/warnings to go and where would you want output to go, and what would you want to throw away? What is generating the password warning and why do you have errors in the MySQL that you don't want to fix?
    – Kusalananda
    Jul 5 '16 at 9:38






  • 1




    mysql prints that warning when you use the -p option on the command line. Instead of fixing it (e.g. by creating a ~/.my.cnf with 600 perms) the OP wants to just ignore and discard the warning (and only that warning, not all of stderr)
    – cas
    Jul 5 '16 at 13:10

















  • probably you should use run_wrapper.sh >> output.log 2>&1
    – Rahul
    Jul 5 '16 at 9:17






  • 1




    I'm not following. Where would you want error/warnings to go and where would you want output to go, and what would you want to throw away? What is generating the password warning and why do you have errors in the MySQL that you don't want to fix?
    – Kusalananda
    Jul 5 '16 at 9:38






  • 1




    mysql prints that warning when you use the -p option on the command line. Instead of fixing it (e.g. by creating a ~/.my.cnf with 600 perms) the OP wants to just ignore and discard the warning (and only that warning, not all of stderr)
    – cas
    Jul 5 '16 at 13:10
















probably you should use run_wrapper.sh >> output.log 2>&1
– Rahul
Jul 5 '16 at 9:17




probably you should use run_wrapper.sh >> output.log 2>&1
– Rahul
Jul 5 '16 at 9:17




1




1




I'm not following. Where would you want error/warnings to go and where would you want output to go, and what would you want to throw away? What is generating the password warning and why do you have errors in the MySQL that you don't want to fix?
– Kusalananda
Jul 5 '16 at 9:38




I'm not following. Where would you want error/warnings to go and where would you want output to go, and what would you want to throw away? What is generating the password warning and why do you have errors in the MySQL that you don't want to fix?
– Kusalananda
Jul 5 '16 at 9:38




1




1




mysql prints that warning when you use the -p option on the command line. Instead of fixing it (e.g. by creating a ~/.my.cnf with 600 perms) the OP wants to just ignore and discard the warning (and only that warning, not all of stderr)
– cas
Jul 5 '16 at 13:10





mysql prints that warning when you use the -p option on the command line. Instead of fixing it (e.g. by creating a ~/.my.cnf with 600 perms) the OP wants to just ignore and discard the warning (and only that warning, not all of stderr)
– cas
Jul 5 '16 at 13:10











5 Answers
5






active

oldest

votes

















up vote
9
down vote













In your bash script, edit it at top



export MYSQL_PWD=yourdbpassword


and mysql query like: mysql -u username -h host db -e "statement"



Reference: From answer posted at Stackoverflow. Other answers can also be followed.






share|improve this answer





























    up vote
    1
    down vote













    It looks like you're missing the stderr redirection from run_wrapper.sh itself, so the errors aren't going through the grep and thence to the log file.



    Try this instead if you're happy to have both stdout and sdterr written to your logfile



    run_wrapper.sh 2>&1 | grep -v "Warning: Using a password" > output.log


    Or if you want only the errors written to the logfile, and stdout left writing to the calling terminal, try this



    ( run_wrapper.sh 2>&1 1>&3 | grep -v "Warning: Using a password" > output.log ) 3>&1





    share|improve this answer



























      up vote
      0
      down vote













      Try this:



      lf='output.log'
      > "$lf" # first truncate/create the logfile.
      run_wrapper.sh >> "$lf" 2> >(grep -v "Warn.*passw.*insec" >> "$lf")


      Redirects stderr via Process Substitution to grep -v ..., and output from that is appended with >> to output.log



      You probably want to use (GNU) grep's --line-buffered option as well as -v to make sure error output isn't delayed.




      If post-processing the log file is an acceptable option for you, you could just delete the unwanted "Warning: " line(s) from the log file after run_wrapper.sh has finished.



      The following shell script fragment saves the timestamp (in $ts) of the log file (in $lf) before running sed -i and restores it afterwards:



      lf='output.log'

      run_wrapper.sh >& "$lf"

      ts=$(date -r "$lf" '+%Y%m%d%H%M.%S')
      sed -i -e '/Warning: Using a password/d' "$lf"
      touch -t "$ts" "$lf"


      If you need to preserve the inode of the log file (e.g. because it has hard links), use ed rather than sed:



      ts=$(date -r "$lf" '+%Y%m%d%H%M.%S')
      printf "%sn" 'g/Warning: Using a password/d' w | ed -s "$lf"
      touch -t "$ts" "$lf"





      share|improve this answer






















      • Thanks for the response. I have tried the suggested option like below
        – jagadish puvvada
        Jul 6 '16 at 5:13











      • sed option creates blank lines and we need to remove them also and it changes file timestamp also
        – jagadish puvvada
        Jul 8 '16 at 5:06










      • The post-process-with-sed option also changes the inode as well as the timestamp - that's normal for -i (and most forms of "in-place" editing"). If run immediately afterwards, it should only be microseconds or seconds different, depending on logfile size of course. But there's no way a d (delete line) command in sed will create a blank line - what exactly do you mean by that?
        – cas
        Jul 8 '16 at 5:15










      • @jagadishpuvvada sed option now saves and restores output.log's timestamp.
        – cas
        Jul 8 '16 at 12:06

















      up vote
      0
      down vote













      search for a line in your wrapper similar to



      mysql -u<username> -p<some_password> -hlocalhost -D<database_name> 


      and change to



      export MYSQL_PWD=<some_password> ; mysql -u<username> -hlocalhost -D<database_name> 


      this solves the source of the warning.






      share|improve this answer



























        up vote
        0
        down vote













        Try adding this to the end of your command:




        /dev/null 2>&1







        share|improve this answer




















          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );








           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f293966%2fsuppress-warning-messages-from-mysql-in-shell-script-but-allow-errors%23new-answer', 'question_page');

          );

          Post as a guest






























          5 Answers
          5






          active

          oldest

          votes








          5 Answers
          5






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          9
          down vote













          In your bash script, edit it at top



          export MYSQL_PWD=yourdbpassword


          and mysql query like: mysql -u username -h host db -e "statement"



          Reference: From answer posted at Stackoverflow. Other answers can also be followed.






          share|improve this answer


























            up vote
            9
            down vote













            In your bash script, edit it at top



            export MYSQL_PWD=yourdbpassword


            and mysql query like: mysql -u username -h host db -e "statement"



            Reference: From answer posted at Stackoverflow. Other answers can also be followed.






            share|improve this answer
























              up vote
              9
              down vote










              up vote
              9
              down vote









              In your bash script, edit it at top



              export MYSQL_PWD=yourdbpassword


              and mysql query like: mysql -u username -h host db -e "statement"



              Reference: From answer posted at Stackoverflow. Other answers can also be followed.






              share|improve this answer














              In your bash script, edit it at top



              export MYSQL_PWD=yourdbpassword


              and mysql query like: mysql -u username -h host db -e "statement"



              Reference: From answer posted at Stackoverflow. Other answers can also be followed.







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Dec 18 '17 at 5:49

























              answered Jan 5 '17 at 6:45









              Lnux

              213310




              213310






















                  up vote
                  1
                  down vote













                  It looks like you're missing the stderr redirection from run_wrapper.sh itself, so the errors aren't going through the grep and thence to the log file.



                  Try this instead if you're happy to have both stdout and sdterr written to your logfile



                  run_wrapper.sh 2>&1 | grep -v "Warning: Using a password" > output.log


                  Or if you want only the errors written to the logfile, and stdout left writing to the calling terminal, try this



                  ( run_wrapper.sh 2>&1 1>&3 | grep -v "Warning: Using a password" > output.log ) 3>&1





                  share|improve this answer
























                    up vote
                    1
                    down vote













                    It looks like you're missing the stderr redirection from run_wrapper.sh itself, so the errors aren't going through the grep and thence to the log file.



                    Try this instead if you're happy to have both stdout and sdterr written to your logfile



                    run_wrapper.sh 2>&1 | grep -v "Warning: Using a password" > output.log


                    Or if you want only the errors written to the logfile, and stdout left writing to the calling terminal, try this



                    ( run_wrapper.sh 2>&1 1>&3 | grep -v "Warning: Using a password" > output.log ) 3>&1





                    share|improve this answer






















                      up vote
                      1
                      down vote










                      up vote
                      1
                      down vote









                      It looks like you're missing the stderr redirection from run_wrapper.sh itself, so the errors aren't going through the grep and thence to the log file.



                      Try this instead if you're happy to have both stdout and sdterr written to your logfile



                      run_wrapper.sh 2>&1 | grep -v "Warning: Using a password" > output.log


                      Or if you want only the errors written to the logfile, and stdout left writing to the calling terminal, try this



                      ( run_wrapper.sh 2>&1 1>&3 | grep -v "Warning: Using a password" > output.log ) 3>&1





                      share|improve this answer












                      It looks like you're missing the stderr redirection from run_wrapper.sh itself, so the errors aren't going through the grep and thence to the log file.



                      Try this instead if you're happy to have both stdout and sdterr written to your logfile



                      run_wrapper.sh 2>&1 | grep -v "Warning: Using a password" > output.log


                      Or if you want only the errors written to the logfile, and stdout left writing to the calling terminal, try this



                      ( run_wrapper.sh 2>&1 1>&3 | grep -v "Warning: Using a password" > output.log ) 3>&1






                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Jul 8 '16 at 12:33









                      roaima

                      39.5k545107




                      39.5k545107




















                          up vote
                          0
                          down vote













                          Try this:



                          lf='output.log'
                          > "$lf" # first truncate/create the logfile.
                          run_wrapper.sh >> "$lf" 2> >(grep -v "Warn.*passw.*insec" >> "$lf")


                          Redirects stderr via Process Substitution to grep -v ..., and output from that is appended with >> to output.log



                          You probably want to use (GNU) grep's --line-buffered option as well as -v to make sure error output isn't delayed.




                          If post-processing the log file is an acceptable option for you, you could just delete the unwanted "Warning: " line(s) from the log file after run_wrapper.sh has finished.



                          The following shell script fragment saves the timestamp (in $ts) of the log file (in $lf) before running sed -i and restores it afterwards:



                          lf='output.log'

                          run_wrapper.sh >& "$lf"

                          ts=$(date -r "$lf" '+%Y%m%d%H%M.%S')
                          sed -i -e '/Warning: Using a password/d' "$lf"
                          touch -t "$ts" "$lf"


                          If you need to preserve the inode of the log file (e.g. because it has hard links), use ed rather than sed:



                          ts=$(date -r "$lf" '+%Y%m%d%H%M.%S')
                          printf "%sn" 'g/Warning: Using a password/d' w | ed -s "$lf"
                          touch -t "$ts" "$lf"





                          share|improve this answer






















                          • Thanks for the response. I have tried the suggested option like below
                            – jagadish puvvada
                            Jul 6 '16 at 5:13











                          • sed option creates blank lines and we need to remove them also and it changes file timestamp also
                            – jagadish puvvada
                            Jul 8 '16 at 5:06










                          • The post-process-with-sed option also changes the inode as well as the timestamp - that's normal for -i (and most forms of "in-place" editing"). If run immediately afterwards, it should only be microseconds or seconds different, depending on logfile size of course. But there's no way a d (delete line) command in sed will create a blank line - what exactly do you mean by that?
                            – cas
                            Jul 8 '16 at 5:15










                          • @jagadishpuvvada sed option now saves and restores output.log's timestamp.
                            – cas
                            Jul 8 '16 at 12:06














                          up vote
                          0
                          down vote













                          Try this:



                          lf='output.log'
                          > "$lf" # first truncate/create the logfile.
                          run_wrapper.sh >> "$lf" 2> >(grep -v "Warn.*passw.*insec" >> "$lf")


                          Redirects stderr via Process Substitution to grep -v ..., and output from that is appended with >> to output.log



                          You probably want to use (GNU) grep's --line-buffered option as well as -v to make sure error output isn't delayed.




                          If post-processing the log file is an acceptable option for you, you could just delete the unwanted "Warning: " line(s) from the log file after run_wrapper.sh has finished.



                          The following shell script fragment saves the timestamp (in $ts) of the log file (in $lf) before running sed -i and restores it afterwards:



                          lf='output.log'

                          run_wrapper.sh >& "$lf"

                          ts=$(date -r "$lf" '+%Y%m%d%H%M.%S')
                          sed -i -e '/Warning: Using a password/d' "$lf"
                          touch -t "$ts" "$lf"


                          If you need to preserve the inode of the log file (e.g. because it has hard links), use ed rather than sed:



                          ts=$(date -r "$lf" '+%Y%m%d%H%M.%S')
                          printf "%sn" 'g/Warning: Using a password/d' w | ed -s "$lf"
                          touch -t "$ts" "$lf"





                          share|improve this answer






















                          • Thanks for the response. I have tried the suggested option like below
                            – jagadish puvvada
                            Jul 6 '16 at 5:13











                          • sed option creates blank lines and we need to remove them also and it changes file timestamp also
                            – jagadish puvvada
                            Jul 8 '16 at 5:06










                          • The post-process-with-sed option also changes the inode as well as the timestamp - that's normal for -i (and most forms of "in-place" editing"). If run immediately afterwards, it should only be microseconds or seconds different, depending on logfile size of course. But there's no way a d (delete line) command in sed will create a blank line - what exactly do you mean by that?
                            – cas
                            Jul 8 '16 at 5:15










                          • @jagadishpuvvada sed option now saves and restores output.log's timestamp.
                            – cas
                            Jul 8 '16 at 12:06












                          up vote
                          0
                          down vote










                          up vote
                          0
                          down vote









                          Try this:



                          lf='output.log'
                          > "$lf" # first truncate/create the logfile.
                          run_wrapper.sh >> "$lf" 2> >(grep -v "Warn.*passw.*insec" >> "$lf")


                          Redirects stderr via Process Substitution to grep -v ..., and output from that is appended with >> to output.log



                          You probably want to use (GNU) grep's --line-buffered option as well as -v to make sure error output isn't delayed.




                          If post-processing the log file is an acceptable option for you, you could just delete the unwanted "Warning: " line(s) from the log file after run_wrapper.sh has finished.



                          The following shell script fragment saves the timestamp (in $ts) of the log file (in $lf) before running sed -i and restores it afterwards:



                          lf='output.log'

                          run_wrapper.sh >& "$lf"

                          ts=$(date -r "$lf" '+%Y%m%d%H%M.%S')
                          sed -i -e '/Warning: Using a password/d' "$lf"
                          touch -t "$ts" "$lf"


                          If you need to preserve the inode of the log file (e.g. because it has hard links), use ed rather than sed:



                          ts=$(date -r "$lf" '+%Y%m%d%H%M.%S')
                          printf "%sn" 'g/Warning: Using a password/d' w | ed -s "$lf"
                          touch -t "$ts" "$lf"





                          share|improve this answer














                          Try this:



                          lf='output.log'
                          > "$lf" # first truncate/create the logfile.
                          run_wrapper.sh >> "$lf" 2> >(grep -v "Warn.*passw.*insec" >> "$lf")


                          Redirects stderr via Process Substitution to grep -v ..., and output from that is appended with >> to output.log



                          You probably want to use (GNU) grep's --line-buffered option as well as -v to make sure error output isn't delayed.




                          If post-processing the log file is an acceptable option for you, you could just delete the unwanted "Warning: " line(s) from the log file after run_wrapper.sh has finished.



                          The following shell script fragment saves the timestamp (in $ts) of the log file (in $lf) before running sed -i and restores it afterwards:



                          lf='output.log'

                          run_wrapper.sh >& "$lf"

                          ts=$(date -r "$lf" '+%Y%m%d%H%M.%S')
                          sed -i -e '/Warning: Using a password/d' "$lf"
                          touch -t "$ts" "$lf"


                          If you need to preserve the inode of the log file (e.g. because it has hard links), use ed rather than sed:



                          ts=$(date -r "$lf" '+%Y%m%d%H%M.%S')
                          printf "%sn" 'g/Warning: Using a password/d' w | ed -s "$lf"
                          touch -t "$ts" "$lf"






                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Jul 8 '16 at 12:12

























                          answered Jul 5 '16 at 13:03









                          cas

                          37.6k44392




                          37.6k44392











                          • Thanks for the response. I have tried the suggested option like below
                            – jagadish puvvada
                            Jul 6 '16 at 5:13











                          • sed option creates blank lines and we need to remove them also and it changes file timestamp also
                            – jagadish puvvada
                            Jul 8 '16 at 5:06










                          • The post-process-with-sed option also changes the inode as well as the timestamp - that's normal for -i (and most forms of "in-place" editing"). If run immediately afterwards, it should only be microseconds or seconds different, depending on logfile size of course. But there's no way a d (delete line) command in sed will create a blank line - what exactly do you mean by that?
                            – cas
                            Jul 8 '16 at 5:15










                          • @jagadishpuvvada sed option now saves and restores output.log's timestamp.
                            – cas
                            Jul 8 '16 at 12:06
















                          • Thanks for the response. I have tried the suggested option like below
                            – jagadish puvvada
                            Jul 6 '16 at 5:13











                          • sed option creates blank lines and we need to remove them also and it changes file timestamp also
                            – jagadish puvvada
                            Jul 8 '16 at 5:06










                          • The post-process-with-sed option also changes the inode as well as the timestamp - that's normal for -i (and most forms of "in-place" editing"). If run immediately afterwards, it should only be microseconds or seconds different, depending on logfile size of course. But there's no way a d (delete line) command in sed will create a blank line - what exactly do you mean by that?
                            – cas
                            Jul 8 '16 at 5:15










                          • @jagadishpuvvada sed option now saves and restores output.log's timestamp.
                            – cas
                            Jul 8 '16 at 12:06















                          Thanks for the response. I have tried the suggested option like below
                          – jagadish puvvada
                          Jul 6 '16 at 5:13





                          Thanks for the response. I have tried the suggested option like below
                          – jagadish puvvada
                          Jul 6 '16 at 5:13













                          sed option creates blank lines and we need to remove them also and it changes file timestamp also
                          – jagadish puvvada
                          Jul 8 '16 at 5:06




                          sed option creates blank lines and we need to remove them also and it changes file timestamp also
                          – jagadish puvvada
                          Jul 8 '16 at 5:06












                          The post-process-with-sed option also changes the inode as well as the timestamp - that's normal for -i (and most forms of "in-place" editing"). If run immediately afterwards, it should only be microseconds or seconds different, depending on logfile size of course. But there's no way a d (delete line) command in sed will create a blank line - what exactly do you mean by that?
                          – cas
                          Jul 8 '16 at 5:15




                          The post-process-with-sed option also changes the inode as well as the timestamp - that's normal for -i (and most forms of "in-place" editing"). If run immediately afterwards, it should only be microseconds or seconds different, depending on logfile size of course. But there's no way a d (delete line) command in sed will create a blank line - what exactly do you mean by that?
                          – cas
                          Jul 8 '16 at 5:15












                          @jagadishpuvvada sed option now saves and restores output.log's timestamp.
                          – cas
                          Jul 8 '16 at 12:06




                          @jagadishpuvvada sed option now saves and restores output.log's timestamp.
                          – cas
                          Jul 8 '16 at 12:06










                          up vote
                          0
                          down vote













                          search for a line in your wrapper similar to



                          mysql -u<username> -p<some_password> -hlocalhost -D<database_name> 


                          and change to



                          export MYSQL_PWD=<some_password> ; mysql -u<username> -hlocalhost -D<database_name> 


                          this solves the source of the warning.






                          share|improve this answer
























                            up vote
                            0
                            down vote













                            search for a line in your wrapper similar to



                            mysql -u<username> -p<some_password> -hlocalhost -D<database_name> 


                            and change to



                            export MYSQL_PWD=<some_password> ; mysql -u<username> -hlocalhost -D<database_name> 


                            this solves the source of the warning.






                            share|improve this answer






















                              up vote
                              0
                              down vote










                              up vote
                              0
                              down vote









                              search for a line in your wrapper similar to



                              mysql -u<username> -p<some_password> -hlocalhost -D<database_name> 


                              and change to



                              export MYSQL_PWD=<some_password> ; mysql -u<username> -hlocalhost -D<database_name> 


                              this solves the source of the warning.






                              share|improve this answer












                              search for a line in your wrapper similar to



                              mysql -u<username> -p<some_password> -hlocalhost -D<database_name> 


                              and change to



                              export MYSQL_PWD=<some_password> ; mysql -u<username> -hlocalhost -D<database_name> 


                              this solves the source of the warning.







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered May 14 '17 at 14:48









                              Mockler

                              1




                              1




















                                  up vote
                                  0
                                  down vote













                                  Try adding this to the end of your command:




                                  /dev/null 2>&1







                                  share|improve this answer
























                                    up vote
                                    0
                                    down vote













                                    Try adding this to the end of your command:




                                    /dev/null 2>&1







                                    share|improve this answer






















                                      up vote
                                      0
                                      down vote










                                      up vote
                                      0
                                      down vote









                                      Try adding this to the end of your command:




                                      /dev/null 2>&1







                                      share|improve this answer












                                      Try adding this to the end of your command:




                                      /dev/null 2>&1








                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered Jun 15 '17 at 1:51









                                      user236164

                                      1




                                      1






















                                           

                                          draft saved


                                          draft discarded


























                                           


                                          draft saved


                                          draft discarded














                                          StackExchange.ready(
                                          function ()
                                          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f293966%2fsuppress-warning-messages-from-mysql-in-shell-script-but-allow-errors%23new-answer', 'question_page');

                                          );

                                          Post as a guest













































































                                          Popular posts from this blog

                                          How to check contact read email or not when send email to Individual?

                                          Bahrain

                                          Postfix configuration issue with fips on centos 7; mailgun relay