MySQL Variables skip_name_resolve 数据库 参数变量解释及正确配置使用
本站中文解释
skip_name_resolve,指定是否要解析用户名以及操作改用户的主机名(hostname),默认值是off。
当skip_name_resolve参数设置为on时,MySQL将不在每次处理连接请求时做hostname解析,而从用户表里直接提取IP地址,提高了性能。
可以在my.cnf(my.ini)文件中加入以下设置来改变skip_name_resolve的值:
skip_name_resolve = 1
或者可以在运行时,使用SET命令来改变skip_name_resolve的值:
SET GLOBAL skip_name_resolve=1;
改完参数后,需要重新启动MySQL服务才会生效。
官方英文解释
skip_name_resolve
Command-Line Format | --skip-name-resolve[={OFF|ON}] |
---|---|
System Variable | skip_name_resolve |
Scope | Global |
Dynamic | No |
Type | Boolean |
Default Value | OFF |
Whether to resolve host names when checking client
connections. If this variable is OFF
,
mysqld resolves host names when checking
client connections. If it is ON
,
mysqld uses only IP numbers; in this case,
all Host
column values in the grant tables
must be IP addresses. See Section 5.1.11.2, “DNS Lookups and the Host Cache”.
Depending on the network configuration of your system and the
Host
values for your accounts, clients may
need to connect using an explicit
--host
option, such as
--host=127.0.0.1
or
--host=::1
.
An attempt to connect to the host 127.0.0.1
normally resolves to the localhost
account.
However, this fails if the server is run with
skip_name_resolve
enabled. If
you plan to do that, make sure an account exists that can
accept a connection. For example, to be able to connect as
root
using
--host=127.0.0.1
or
--host=::1
, create these
accounts:
CREATE USER 'root'@'127.0.0.1' IDENTIFIED BY 'root-password
'; CREATE USER 'root'@'::1' IDENTIFIED BY 'root-password
';