-2
mysql -hhost -uuser -ppassword

Is there a rationale behind why there's no need for spaces? In fact, it wouldn't work unless there is no space.

geoyws
  • 3,326
  • 3
  • 35
  • 47

2 Answers2

1

Found my answer:

https://dev.mysql.com/doc/refman/5.7/en/command-line-options.html

It's just the way they wrote it.

geoyws
  • 3,326
  • 3
  • 35
  • 47
0

If you use a command like

mysql -h hostname -u username -p xxx

the command is ambiguous. It could mean that xxx is the password and no database was specified, or it could mean that xxx is the database and no password was specified (in which case mysql prompts for a password).

They chose the second interpretation. But if you use -pxxx then xxx can only be interpreted as the password.

Barmar
  • 741,623
  • 53
  • 500
  • 612