I'm trying to use mysqldump
to dump a schema, and it mostly works but I ran into one curiosity: the -p
or --password
option seems like it is doing something other than setting the password (as the man
page and --help
output say it should).
Specifically, it looks like it's doing what is indicated here: http://snippets.dzone.com/posts/show/360 - that is, setting the database to dump.
To support my somewhat outlandish claim, I can tell you that if I do not specify the --password
(or -p
) option, the command prints the usage statement and exits with an error. If I do specify it, I am immediately prompted to enter a password (!), and then the database specified in the --password
option is dumped (or an error is given in the usual case that a password not matching any database name was specified).
Here's a transcript:
$ mysqldump -u test -h myhost --no-data --tables --password lose Enter password: -- MySQL dump 10.10 mysqldump: Got error: 1044: Access denied for user 'test'@'%' to database 'lose' when selecting the database
So, what gives? Is this the way this is supposed to work? It surely does not appear to make sense nor does it match the official documentation. And finally, if this just the way it works, how am I meant to specify the password to be used in an automated job? Using expect
???
I'm using mysqldump Ver 10.10 Distrib 5.0.22, for pc-linux-gnu (i486)
.