传递版本属性时 mysql 版本的差异

Differences in mysql version when passing version attribute

为什么会出现以下情况?

$ mysql --version
mysql  Ver 14.14 Distrib 5.7.16, for osx10.11 (x86_64) using  EditLine wrapper

$ mysql -v
ERROR 1045 (28000): Access denied for user 'xxx'@'localhost' (using password: NO)

mysql有两个版本吗?我如何摆脱不是 mysql Ver 14.14 Distrib 5.7.16 的那个?

我认为您混淆了 --version-v。来自 MySQL documentation:

Option names are case sensitive. -v and -V are both legal and have different meanings. (They are the corresponding short forms of the --verbose and --version options.)

我认为当您键入 mysql -v 时,您试图在启动 MySQL 时打开某种冗长的标志。无论如何,您没有指定用户名或密码。因此它尝试使用您的 Linux 用户名而不设置密码,但失败了。