简体   繁体   English

使用mysql cli连接时,为什么-p和密码之间没有空格? 例如 -ppassword

[英]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 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).这可能意味着xxx是密码并且没有指定数据库,或者可能意味着xxx是数据库并且没有指定密码(在这种情况下mysql提示输入密码)。

They chose the second interpretation.他们选择了第二种解释。 But if you use -pxxx then xxx can only be interpreted as the password.但是如果你使用-pxxx那么xxx只能被解释为密码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将 dokku MySQL 连接到数据库 GUI(例如 Sequel Ace 或 Sequel pro) - Connecting dokku MySQL to a database GUI (e.g. Sequel Ace or Sequel pro) 在编译的可执行文件中加密常量字符串(例如,密码) - Encrypting constant strings(e.g. Password) in compiled executable 如果出现问题,如何在升级时保存旧版本的Linux应用程序(例如MySQL)? - How to save old version of Linux app when upgrading (e.g. MySQL) in case of problems? 当名称中的名称可能略有不同时(例如“ Matt”与“ Mathew”),在Mysql中管理名称 - Managing Names in Mysql when they can be slightly different (e.g. “Matt” vs “Mathew”) MySQL查询utf-8字符(例如中文)(另外,我使用的是Doctrine) - MySQL query utf-8 characters (e.g. Chinese)(Also, I am using Doctrine) MySQL-表中的第二个序列(例如按类别) - MySQL - second sequence in table (e.g. by category) Mysql:选择未分配的记录,例如分配给特定组 - Mysql: Select records which are NOT assigned e.g. to a specific group 删除/更新mysql或在代码中处理此问题(例如PHP) - mysql on Delete/Update or handle this in Code (e.g. PHP) MySQL-SQL跳过间隔,例如每5分钟记录一次 - MySQL - SQL to skip intervals e.g. records every 5 minutes MySQL:如何设计转换表(例如服装尺寸)? - MySQL: How to design table for conversion (e.g. dress sizes)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM