简体   繁体   中英

When connecting using the mysql cli, why is there no space between -p and the password? e.g. -ppassword

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.

Found my answer:

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

It's just the way they wrote it.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM