我想将127.0.0.1映射到多个名称,而不是将标准方式映射为localhost.因此我在Ubuntu中的/etc/hosts文件将包含以下条目:
I want to map 127.0.0.1 to multiple names instead of the standard way as localhost. so my /etc/hosts file in Ubuntu would have the following entries:
127.0.0.1 localhost 127.0.0.1 localhost:extra1 127.0.0.1 localhost:extra2现在,在MySQL中,我想要一个名为karthick的用户,它应该具有不同的特权.
Now, in MySQL, I want to have a user named karthick and it should have different privileges.
select user,host from users;上面的语句显示
karthick localhost:extra1; karthick localhost:extra2;我的问题:
我无法使用
mysql -u karthick -h localhost:extra1 -p怎么了?
问题背后的动机
Motivation behind the question
我要按以下方式登录
登录1:
mysql -u karthick -h localhost:extra1 -p登录2:
mysql -u karthick -h localhost:extra2 -p我希望登录名1和登录名2具有不同的特权集...希望这是可能的
I want login 1 and login 2 to have different set of privileges... Hope this is possible
推荐答案在mysql接收连接的那一刻,它所需要识别的远程系统就是 IP地址.然后,它必须执行反向dns"查找,以将请求系统的IP地址转换为主机名,以便它可以在授权表中查找主机名.尽管您可以将多个主机名映射到一个IP地址,但是,mysql无法知道最初指定的主机名.届时,它所具有的只是127.0.0.1,DNS解析器将返回名称"localhost".即使更改了该名称,您也只能给它起一个名字,这样您的方案就行不通了.
At the point where mysql receives the connection, all it has to identify the remote system is the IP address. It must then do a "reverse dns" lookup to convert the IP address of the requesting system to a hostname, so that it can look up the hostname in the authorization table. While you can map multiple hostnames to a single IP address, as you have done, there's no way for mysql to know which hostname was originally specified. At that point all it has is 127.0.0.1, and the DNS resolver will return the name 'localhost'. Even if changed that, you could give it only one name, so your scheme won't work.
但是,您可以为您的网络适配器提供多个不同的IP地址.我不知道在Ubuntu上进行设置的细节,但这应该相对容易.然后,您可以设置多个主机名,每个主机名都有自己的IP,该IP连接回系统.在mysql设置中,请在GRANT命令中指定IP地址而不是主机名,以避免麻烦rDNS.
You can however give your network adapter multiple DIFFERENT IP addresses. I don't know the details of setting this up on Ubuntu, but it should be relatively easy. Then you can set up multiple hostnames each with its own IP that connects back to your system. In your mysql setup specify the IP addresses instead of the hostnames in your GRANT commands to avoid having to mess with rDNS.
更多推荐
多个主机名和多个特权?
发布评论