创建 MySQL 用户时使用 % 作为主机 [英] Using % for host when creating a MySQL user

查看:42
本文介绍了创建 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 用户时使用 % 作为主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆