我正在关注有关udemy的教程,但我一直坚持设置新用户。我已经设法做到最好,但是本教程使用phpmyadmin,现在我在工作台上。
谁能解释“主机匹配限制”的用途?是否仅允许访问具有特定IP地址或域名的用户?我只是在本地服务器上运行,可以为项目使用root,但是,嘿,我必须在某个阶段学习它,为什么现在不这样做?
答案 0 :(得分:1)
严格来说,这不是MySQL Workbench的问题,但对于用户创建而言却是必不可少的:主机部分可以是主机名(由MySQL解析为IP地址)或IP地址(IPv4或IPv6)。这些值确定了用户可以从哪个主机连接,从运行MySQL服务器的主机来看(例如localhost
表示MySQL服务器计算机,而不是您从其连接的计算机,除非是同一盒子)。对于每种变体,您可以使用通配符和占位符来匹配一系列计算机。
MySQL documentation的此页面描述了匹配过程并显示了示例:
The following table shows how various combinations of User and Host values in the user table apply to incoming connections.
╔═════════════╦═══════════════════════════════╦═══════════════════════════════════════════════════════════════════════════════════════════════════════════╗
║ User Value ║ Host Value ║ Permissible Connections ║
╠═════════════╬═══════════════════════════════╬═══════════════════════════════════════════════════════════════════════════════════════════════════════════╣
║ 'fred' ║ 'h1.example.net' ║ fred, connecting from h1.example.net ║
║ '' ║ 'h1.example.net' ║ Any user, connecting from h1.example.net ║
║ 'fred' ║ '%' ║ fred, connecting from any host ║
║ '' ║ '%' ║ Any user, connecting from any host ║
║ 'fred' ║ '%.example.net' ║ fred, connecting from any host in the example.net domain ║
║ 'fred' ║ 'x.example.%' ║ fred, connecting from x.example.net, x.example.com, x.example.edu, and so on; this is probably not useful ║
║ 'fred' ║ '198.51.100.177' ║ fred, connecting from the host with IP address 198.51.100.177 ║
║ 'fred' ║ '198.51.100.%' ║ fred, connecting from any host in the 198.51.100 class C subnet ║
║ 'fred' ║ '198.51.100.0/255.255.255.0' ║ Same as previous example ║
╚═════════════╩═══════════════════════════════╩═══════════════════════════════════════════════════════════════════════════════════════════════════════════╝