MySQL, -p, and no space between password

Last Modified: Fri, 10 Apr 2009 15:37:46 +0000 ; Created: Fri, 10 Apr 2009 15:37:46 +0000

So for the mysql command line utilities (ex: mysqldump) you can specify the password on the command-line with -pPASSWORD or --password=PASSWORD. You cannot have a space in between like "-p PASSWORD".

I was wondering why and found the following bug report that explains it. In short the password value is optional since -p alone means prompt the user for the password. Most other utilities use something like "-p -" to indicate prompt from STDIN for the password. MySQL does not.

One shouldn't pass the password on the command-line anyway. You're better off putting it in a mysql.ini and securing the file instead if you need it for automation.