I have a question, What is the significance of the whitespace after the user flag -u inside a mysql connection string?
mysql -u myname -pmypass mydb
I mean to say, the above command works just fine, if I don't pass a whitespace after -u and just write the above command as below.
mysql -umyname -pmypass mydb
I tried searching for an explaination by using the following search terms.
mysql login whitespace after user flag
mysql connection console whitespace after user flag
I found the mention of whitespace after the password flag -p, Here. But the page no where talks about the whitespace after the user flag -u.
....there must be no space between -p or --password= and the password following it.
解决方案
The -p option takes an optional argument:
mysql --help --verbose
...
-p, --password[=name]
Password to use when connecting to server. If password is
not given it's asked from the tty.
So, a command line that contains:
-p mydb
would be ambiguous ... does this means to:
Prompt the user for a password, and use the mydb database ?
Use the password mydb, and not set a default database ?
This is why the documentation insists on a particular rule for the password option: the value, if given, must be attached (no space).
For options that always take an argument, like -u, there are no special considerations, so the white space is not significant.
See the manual for a full documentation of command line options: