是否需要将MySQL用户添加到MySQL“系统”中?是否需要将MySQL用户添加到MySQL“系统”?
我在学习MySQL基础知识,但这个问题刚刚出现。这是为什么:
:~$ mysql -u johndoe
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 50
Server version: 5.5.24-0ubuntu0.12.04.1 (Ubuntu)
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> SELECT User();
+-------------------+
| User() |
+-------------------+
| [email protected] |
+-------------------+
1 row in set (0.00 sec)
mysql> quit
Bye
当然,我没有设置一个名为johndoe的用户,但似乎我可以用任何用户名输入mysql。我并不是说我会看到任何数据库,因为它可能没有设置任何数据库,例如johndoe可以做些事情。
所以我的问题最后是:这是真的还是我看到它是错误的?
如果你可以用随机用户登录mysql,这意味着你正在用'--skip-grant-tables'运行你的服务器。 – golja 2012-07-06 00:39:29
不是。你可以看到@SelloLekgothoane答案,或者按照以下链接:[function_current-user](http://dev.mysql.com/doc/refman/5.1/en/information-functions.html#function_current-user),[function_user] (http://dev.mysql.com/doc/refman/5.1/en/information-functions.html#function_user)和[account-activity-auditing](http://dev.mysql.com/doc/refman/ 5.1/EN /帐户 - 活性 - auditing.html)。 – Miguel 2012-07-06 04:06:33
您也可以关注[此链接](http://dev.mysql.com/doc/refman/5.1/en/default-privileges.html),非常明确。确实是 – Miguel 2012-07-06 14:34:36