MySQL:% 在主机列中代表什么以及如何更改用户密码 [英] MySQL: What does % stand for in host column and how to change user's password

查看:54
本文介绍了MySQL:% 在主机列中代表什么以及如何更改用户密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗯,这是我能看到的:

select host, user from mysql.user;

+-----------+------------------+
| host      | user             |
+-----------+------------------+
| %         | me               |
| 127.0.0.1 | root             |
| ::1       | root             |
| localhost |                  |
| localhost | debian-sys-maint |
| localhost | root             |
| ubuntu    |                  |
| ubuntu    | root             |
+-----------+------------------+

我以 root 用户身份进入并想更改用户me"的密码.

I entered as root and would like to change password for user 'me'.

SET PASSWORD FOR 'me'@'%' = PASSWORD('letmein');
Query OK, 0 rows affected (0.00 sec)

好吧,正如我们所见,没有任何行受到影响.

Well, no rows affected as we can see.

至于尝试访问,结果如下:

As for trying to access, the result is as follows:

Access denied for user 'me'@'localhost' (using password: YES)
michael@ubuntu:/var/www/cgi-bin$ 

所以,它提到了 localhost,而不是 %.

So, it mentions localhost, not %.

您能否建议我如何更改我"的密码并解释 % 是什么?

Could you suggest me how to change the password for 'me' and explain what % is?

推荐答案

localhost需要设置密码:

SET PASSWORD FOR 'me'@'localhost' = PASSWORD('letmein');

FLUSH PRIVILEGES;

% 表示远程主机可以从任何其他服务器登录 MySQL 服务器,而 localhost 表示您只能从同一台机器登录 MySQL 服务器.

% means remote hosts can login to MySQL server from any other server whereas localhost means you can login to MySQL server only from same machine.

这篇关于MySQL:% 在主机列中代表什么以及如何更改用户密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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