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.
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
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:or
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
rootor you executedsudo, you have unquestioned rights to doing aDROP DATABASE IF EXISTS. At the OS level, mysqld would attempt to discard the folder for the database.For example, if datadir is
/var/lib/mysqland you executeDROp DATABASE IF EXISTS rolando;, mysqld will attempt to runrm -rf /var/lib/mysql/rolando.if you are not
rootorsudo‘d asroot, 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 attemptedservice mysql stop.UPDATE 2013-01-25 16:54 EDT
mysqladmin does not cause prompting either, except for passwords. Here are all its options:
HEY, I STAND CORRECTED
--forcedoes prompt for DROP DATABASEOK I guess you located the culprit. I learned something today because I do not use
mysqladminto drop databases.