Using % for host when creating a MySQL user(创建 MySQL 用户时使用 % 作为主机)
问题描述
我的 MySQL 数据库需要两个用户:appuser 和 support.
其中一位应用程序开发人员坚持要求我为这些用户创建四个帐户:
My MySQL database needs two users: appuser and support.
One of the application developers insists that I create four accounts for these users:
appuser@'%'
appuser@'localhost'
support@'%'
support@'localhost'
就我的一生而言,我无法弄清楚他为什么认为我们需要这个.主机不会使用通配符来处理 'localhost' 吗?
For the life of me I can't figure out why he thinks we need this. Wouldn't using the wildcard as the host take care of the 'localhost'?
有什么想法吗?
(此处使用 MySQL 5.5)
(Using MySQL 5.5 here)
推荐答案
localhost
在 MySQL 中是特殊的,它意味着通过 UNIX 套接字(或 Windows 上的命名管道,我相信)上的连接,而不是到 TCP/IP 套接字.使用 %
作为主机不包含 localhost
,因此需要明确指定.
localhost
is special in MySQL, it means a connection over a UNIX socket (or named pipes on Windows, I believe) as opposed to a TCP/IP socket. Using %
as the host does not include localhost
, hence the need to explicitly specify it.
这篇关于创建 MySQL 用户时使用 % 作为主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:创建 MySQL 用户时使用 % 作为主机


基础教程推荐
- 带有WHERE子句的LAG()函数 2022-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- 带更新的 sqlite CTE 2022-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01