我通过 Nix 安装了 MariaDB,但在通过 TCP 连接时遇到了问题。
我拥有如下用户:
MariaDB [(none)]> SELECT User, Host FROM mysql.user;
+---------------+-----------+-------------------------------------------+
| User | Host | Password |
+---------------+-----------+-------------------------------------------+
| | localhost | |
| foo | % | *E8D46CE25265E545D225A8A6F1BAF642FEBEE5CB |
+---------------+-----------+-------------------------------------------+
2 rows in set (0.004 sec)
(还有其他行,但这就是全部了foo
)
如果我尝试与用户连接foo
:
[1] jason@goodness> mysql -h127.0.0.1 -ufoo -pbar
ERROR 1045 (28000): Access denied for user 'foo'@'localhost' (using password: YES)
并且没有密码(我认为它会以某种方式回到匿名用户):
jason@goodness> mysql -h127.0.0.1 -ufoo
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 20
Server version: 10.6.7-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> SELECT USER(), CURRENT_USER();
+---------------+----------------+
| USER() | CURRENT_USER() |
+---------------+----------------+
| foo@localhost | @localhost |
+---------------+----------------+
1 row in set (0.001 sec)
问题 1为什么错误消息和USER()
函数都显示foo@localhost
而不是[email protected]
?
我尝试使用 MySQL 5.7 执行相同的操作,并且它的结果[email protected]
与我预期的一致。
现状与此相矛盾:
MariaDB [(none)]> status
--------------
mysql Ver 15.1 Distrib 10.6.7-MariaDB, for osx10.17 (arm64) using EditLine wrapper
Connection id: 6
Current database:
Current user: foo@localhost
SSL: Not in use
Current pager: less -R
Using outfile: ''
Using delimiter: ;
Server: MariaDB
Server version: 10.6.7-MariaDB MariaDB Server
Protocol version: 10
Connection: 127.0.0.1 via TCP/IP
Server characterset: utf8mb4
Db characterset: utf8mb4
Client characterset: utf8mb3
Conn. characterset: utf8mb3
TCP port: 3306
Uptime: 1 min 51 sec
Threads: 1 Questions: 49 Slow queries: 0 Opens: 37 Open tables: 30 Queries per second avg: 0.441
--------------
这里说的“当前用户”是foo@localhost
不正确的CURRENT_USER()
(也没有任何其他错误说是当前用户)。
它还说连接是127.0.0.1 via TCP/IP
如此,我不知道为什么USER()
,CURRENT_USER()
并且status
都会说@localhost
。
第二季度这种不一致是否与访问被拒绝错误有关(因为没有foo@localhost
)或者这只是一个转移注意力的花招?
第三季度如何通过 TCP 登录foo
?