mysql - MariaDB 10.1.12,使用 -p 时控制台没有响应

标签 mysql mariadb

当我使用给定用户的密码时,我突然无法再登录本地(Windows 7 64)数据库(MariaDB 10.1.12)。我还有另一个 MySQL 在 Vagrant (Ubuntu32 14.04) 中运行,因此 --port 3305对于其中的 Windows 而言。

$ mysql --version C:\Program Files\MariaDB 10.1\bin\mysql.exe Ver 15.1 Distrib 10.1.12-MariaDB, for Win64 (AMD64)

Windows/Git Bash 中给出的所有命令:

$ mysql --port 3305 ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: NO)
错误消息几乎立即出现,并且是预期的。

然后使用存在的用户名(不是字面上的下面的用户名):
$ mysql --port 3305 -u my_username ERROR 1045 (28000): Access denied for user 'my_username'@'localhost' (using password: NO)
同样,错误消息按预期立即出现。

问题:
在同一个控制台中,此命令永远不会得到任何响应。就像 MariaDB 挂起/卡住(直到 Ctrl + C),即使在后台等待一个小时后也是如此。这似乎只发生在 -p 时参数设置:

$ mysql --port 3305 -u my_username -pcorrect_password

$ mysql --port 3305 -u my_username -p

对于后一种情况,应该会出现密码提示,但它也永远不会出现。这个配置以前有效,并且(据我所知)没有任何改变? MariaDB 本身正在工作,因为它确实响应其他命令。为什么密码提示会挂起它?

最佳答案

因为Mariadb客户端也继承了很多MySQL代码和行为,所以Mysql文档里面写的是:Connecting to the MySQL Server mariadb 客户端也可能发生这种情况。

On Unix, MySQL programs treat the host name localhost specially, in a way that is likely different from what you expect compared to other network-based programs. For connections to localhost, MySQL programs attempt to connect to the local server by using a Unix socket file. This occurs even if a --port or -P option is given to specify a port number. To ensure that the client makes a TCP/IP connection to the local server, use --host or -h to specify a host name value of 127.0.0.1, or the IP address or name of the local server. You can also specify the connection protocol explicitly, even for localhost

显然,即使使用 --port 参数,mariadb 客户端也会连接到 3305。由于端口 3305 未运行 maraidb 代理,但端口已打开,因此 mariadb 客户端只需等待超时(典型的 TCP/IP 客户端工具行为)。如果 3305 没有打开,mariadb 客户端会 ASAP 给出连接失败。

关于mysql - MariaDB 10.1.12,使用 -p 时控制台没有响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37204161/

相关文章:

php - MariaDB 服务器版本,可在附近使用正确的语法

mysql - 将索引提升为主键

mysql - 如何比较表中的2个字段并制作状态字段

mysql - RMariaDB : caching_sha2_password error when connecting to MySQL

通过 mysql.sock 在重负载下的 PHP/MYSQL 连接失败

c# - 从 sql 获取值并将它们放在复选框上

MYSQL boolean 类型

php - 从类中的函数获取具有特定内容的变量

php - SQL - 选择用户名 WHERE 角色 = $string

mysql - session 终止(事务回滚)后更新触发器是否被终止?