用户'User'@'%'和'User'@'localhost'是否不同? [英] Are Users 'User'@'%' and 'User'@'localhost' not the same?

查看:398
本文介绍了用户'User'@'%'和'User'@'localhost'是否不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我根据第一个命令创建了一个用户,但是无法通过localhost(linux)登录.此链接 mysqldoc 表示我需要创建另一个具有相同名称的用户,但使用第二个命令块中的语法.

I created a user per the first command but cannot logon via localhost (linux). This link mysqldoc indicates that I need to create a second user by the same name, but using the syntax in the second block of commands.

mysql> CREATE USER 'myuser'@'%' IDENTIFIED BY '4myuser';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL ON my_upload.* TO 'myuser'@'%' IDENTIFIED BY '4myuser';
Query OK, 0 rows affected (0.00 sec)

因此,我尝试如下进行操作,并且确实有效.但是,这两个用户是分开的吗?如果我将一个密码更改为另一个密码,另一个密码会同步吗,或者它们确实是分开的用户?

So I tried that as below, and it indeed worked. But are these two separate users? If I change the pw for one, will the other one sync, or are they truly separate users?

mysql> CREATE USER 'myuser'@'localhost' IDENTIFIED BY '4myuser';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON my_upload.* TO  'myuser'@'localhost';
Query OK, 0 rows affected (0.00 sec)

推荐答案

User@%将允许从所有位置进行访问. User@localhost仅允许从本地主机访问.他们是两个不同的用户,具有两个不同的密码(尽管您可以将它们设置为相同的密码,但是如果您更新一个密码,另一个将不会自动更新)

User@% would allow access from all locations. User@localhost would only allow access from localhost. They are two different users with two different passwords (though you can set them to the same password, but if you update one password the other will not auto-update)

这篇关于用户'User'@'%'和'User'@'localhost'是否不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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