gpt4 book ai didi

mysql - mysql.user 表中的 127.0.0.1、localhost、[hostname] 有什么区别

转载 作者:可可西里 更新时间:2023-11-01 07:33:31 25 4
gpt4 key购买 nike

下面是来自全新安装的 MySQL 5 的查询select host, user from mysql.user 的结果。

+-----------+------------------+
| host | user |
+-----------+------------------+
| 127.0.0.1 | root |
| localhost | debian-sys-maint |
| localhost | root |
| ubuntu | root |
+-----------+------------------+

127.0.0.1localhostubuntu都指向同一台机器,也就是 native 。从表中删除看似重复的主机/用户对的行后,我找不到任何区别。

它们之间有什么区别?我可以安全地移除另外两个吗?

最佳答案

来自 the manual :

When you install MySQL, the grant tables are populated with an initial set of accounts. The names and access privileges for these accounts are described in Section 2.10.3, “Securing the Initial MySQL Accounts”, which also discusses how to assign passwords to them.

And:

Some accounts have the user name root. These are superuser accounts that have all privileges and can do anything. The initial root account passwords are empty, so anyone can connect to the MySQL server as root without a password and be granted all privileges.

On Unix, each root account permits connections from the local host. Connections can be made by specifying a host name of localhost or the actual host name or IP address.

但是,我找不到任何理由。手册中没有其他内容表明出于任何特定原因需要,但大概是为了涵盖 request verification 的所有基础。 .在某些情况下,一个发起本地连接使用一个帐户而其他人需要使用其他帐户;我猜想确保本地 root 访问将始终有效,无论在什么边缘情况下,都是一件好事。

关于mysql - mysql.user 表中的 127.0.0.1、localhost、[hostname] 有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7644704/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com