Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9191467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:41:27+00:00 2026-06-17T20:41:27+00:00

I have a shell script that does the following mysql -uuser -ppass -e DROP

  • 0

I have a shell script that does the following

mysql -uuser -ppass -e "DROP DATABASE IF EXISTS database"

However, this brings up a prompt if you’re sure you want to do that [Y/N]. I need this in a script so is there a way to force it execute? --force option in documentation talks about not stopping for errors.

EDIT: mysql client in fact does not generate prompt. It turns out I had mysqladmin client call that was generating the prompt.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T20:41:28+00:00Added an answer on June 17, 2026 at 8:41 pm

    It is evident that the shell script is waiting for the Y/N response and not the MySQL client.

    You should be able to execute the line directly by just copying/pasting

    mysql -uuser -ppass -e "DROP DATABASE IF EXISTS database"
    

    at the Linux command prompt.

    If you prefer, where this command appears, simply comment out the Y/N response from the shell script.

    My next suggestion would be for you look into your my.cnf.

    See if there is a [mysql] or [client] section with the following:

    [mysql]
    i-am-a-dummy
    safe-updates
    

    or

    [client]
    i-am-a-dummy
    safe-updates
    

    Those are real options: See safe-updates and i-am-a-dummy in the MySQL Documentation

    UPDATE 2013-01-25 16:48 EDT

    My next guess would be the Operating System. Why ???

    If you are logged into Linux as root or you executed sudo, you have unquestioned rights to doing a DROP DATABASE IF EXISTS. At the OS level, mysqld would attempt to discard the folder for the database.

    For example, if datadir is /var/lib/mysql and you execute DROp DATABASE IF EXISTS rolando;, mysqld will attempt to run rm -rf /var/lib/mysql/rolando.

    if you are not root or sudo‘d as root, I would expect the OS to echo that message. In fact, I have seen a message from the OS ask to delete a PID file when I was not logged in as root and attempted service mysql stop.

    UPDATE 2013-01-25 16:54 EDT

    mysqladmin does not cause prompting either, except for passwords. Here are all its options:

    [root@***]# mysqladmin --help
    mysqladmin  Ver 8.42 Distrib 5.1.47, for redhat-linux-gnu on x86_64
    Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
    This software comes with ABSOLUTELY NO WARRANTY. This is free software,
    and you are welcome to modify and redistribute it under the GPL license
    
    Administration program for the mysqld daemon.
    Usage: mysqladmin [OPTIONS] command command....
      -c, --count=#       Number of iterations to make. This works with -i
                          (--sleep) only.
      --debug-check       Check memory and open file usage at exit.
      --debug-info        Print some debug info at exit.
      -f, --force         Don't ask for confirmation on drop database; with
                          multiple commands, continue even if an error occurs.
      -C, --compress      Use compression in server/client protocol.
      --character-sets-dir=name
                          Directory for character set files.
      --default-character-set=name
                          Set the default character set.
      -?, --help          Display this help and exit.
      -h, --host=name     Connect to host.
      -b, --no-beep       Turn off beep on error.
      -p, --password[=name]
                          Password to use when connecting to server. If password is
                          not given it's asked from the tty.
      -P, --port=#        Port number to use for connection or 0 for default to, in
                          order of preference, my.cnf, $MYSQL_TCP_PORT,
                          /etc/services, built-in default (3306).
      --protocol=name     The protocol to use for connection (tcp, socket, pipe,
                          memory).
      -r, --relative      Show difference between current and previous values when
                          used with -i. Currently only works with extended-status.
      -O, --set-variable=name
                          Change the value of a variable. Please note that this
                          option is deprecated; you can set variables directly with
                          --variable-name=value.
      -s, --silent        Silently exit if one can't connect to server.
      -S, --socket=name   The socket file to use for connection.
      -i, --sleep=#       Execute commands repeatedly with a sleep between.
      --ssl               Enable SSL for connection (automatically enabled with
                          other flags). Disable with --skip-ssl.
      --ssl-ca=name       CA file in PEM format (check OpenSSL docs, implies
                          --ssl).
      --ssl-capath=name   CA directory (check OpenSSL docs, implies --ssl).
      --ssl-cert=name     X509 cert in PEM format (implies --ssl).
      --ssl-cipher=name   SSL cipher to use (implies --ssl).
      --ssl-key=name      X509 key in PEM format (implies --ssl).
      --ssl-verify-server-cert
                          Verify server's "Common Name" in its cert against
                          hostname used when connecting. This option is disabled by
                          default.
      -u, --user=name     User for login if not current user.
      -v, --verbose       Write more information.
      -V, --version       Output version information and exit.
      -E, --vertical      Print output vertically. Is similar to --relative, but
                          prints output vertically.
      -w, --wait[=#]      Wait and retry if connection is down.
      --connect_timeout=#
      --shutdown_timeout=#
    

    HEY, I STAND CORRECTED

    --force does prompt for DROP DATABASE

    OK I guess you located the culprit. I learned something today because I do not use mysqladmin to drop databases.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a C shell script that does something like this: #!/bin/csh gcc example.c
I have a shell script file (run.sh) that contains the following: #!/bin/bash %JAVA_HOME%/bin/java -jar
I am trying write a shell script that does the following: Checks the remote
I have the following line in a shell script: source bash_profile It does not
I have a shell script that contains the following loop. i=0 upperlimit=$verylargevariable do complexstuff
I have a simple main shell script that does a few prep things and
Have a shell script that reads the files in a particular directory. #!/bin/bash for
I have a shell script that launches a Maven exec:java process - exec mvn
I have a Bourne Shell script that has several functions in it, and allows
I have a PHP script that I'm invoking from another shell script that sends

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.