Ответ 1
Очевидно, что оболочка script ждет ответ Y/N, а не клиент MySQL.
Вы должны иметь возможность выполнять прямую прямую, просто копируя/вставляя
mysql -uuser -ppass -e "DROP DATABASE IF EXISTS database"
в командной строке Linux.
Если вы предпочитаете, где эта команда появляется, просто закомментируйте ответ Y/N из оболочки script.
Мое следующее предложение было бы для вас заглянуть в ваш my.cnf.
Посмотрите, есть ли раздел [mysql]
или [client]
со следующим:
[mysql]
i-am-a-dummy
safe-updates
или
[client]
i-am-a-dummy
safe-updates
Это реальные варианты: см. безопасные обновления и i-am-a-dummy в документации по MySQL
ОБНОВЛЕНИЕ 2013-01-25 16:48 EDT
Мое следующее предположение - это операционная система. Почему???
Если вы вошли в Linux как root
или выполнили sudo
, у вас есть неоспоримые права на выполнение DROP DATABASE IF EXISTS
. На уровне ОС mysqld попытается отбросить папку для базы данных.
Например, если datadir /var/lib/mysql
и вы выполняете DROp DATABASE IF EXISTS rolando;
, mysqld попытается запустить rm -rf /var/lib/mysql/rolando
.
если вы не root
или sudo
'd как root
, я бы ожидал, что ОС будет эхо-сообщение. Фактически, я видел сообщение от ОС, прошу удалить файл PID, когда я не был зарегистрирован как root и попытался service mysql stop
.
ОБНОВЛЕНИЕ 2013-01-25 16:54 EDT
mysqladmin не вызывает подсказки, кроме паролей. Вот все его варианты:
[[email protected]***]# 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 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 "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=#
ЭТО, Я ПРАВИЛЬНО ИСПРАВЛЕНО
--force
запрашивает DATPASE DATABASE
ОК, я думаю, вы обнаружили преступника. Сегодня я чему-то научился, потому что я не использую mysqladmin
для сброса баз данных.