gpt4 book ai didi

mysql - 用户名中的通配符

转载 作者:行者123 更新时间:2023-11-29 04:46:34 25 4
gpt4 key购买 nike

我正在尝试将我的 MySQL 服务器设置为允许从用户名为 bob* 的连接进行访问。* 代表任意字符组合。例如,我有三个用户名为 bob1、bob2、bobMaster 的帐户。但是当我输入 bob% 作为用户名时,它说访问被拒绝。我使用了错误的通配符还是错误的格式?提前致谢。

最佳答案

你不能那样做。

MySQL 支持host_name 中的通配符,但不支持user_name 中的通配符。

manual 中所述:

A user name is either a nonblank value that literally matches the user name for incoming connection attempts, or a blank value (empty string) that matches any user name. An account with a blank user name is an anonymous user. To specify an anonymous user in SQL statements, use a quoted empty user name part, such as ''@'localhost'.

You can use the wildcard characters “%” and “_” in host name or IP address values. These have the same meaning as for pattern-matching operations performed with the LIKE operator. For example, a host value of '%' matches any host name, whereas a value of '%.mysql.com' matches any host in the mysql.com domain. '192.168.1.%' matches any host in the 192.168.1 class C network.

Because you can use IP wildcard values in host values (for example, '192.168.1.%' to match every host on a subnet), someone could try to exploit this capability by naming a host 192.168.1.somewhere.com. To foil such attempts, MySQL disallows matching on host names that start with digits and a dot. Thus, if you have a host named something like 1.2.example.com, its name never matches the host part of account names. An IP wildcard value can match only IP addresses, not host names.

关于mysql - 用户名中的通配符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18152995/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com