然后,我开始想我应该问每个人这个问题:
多年来,我一直注意到在安装 MySQL 5.0+ 时,mysql.db填充了两个条目,允许匿名用户访问测试数据库。
您可以通过运行此查询来查看它:
mysql> select * from mysql.db where SUBSTR(db,1,4) = 'test'\G
*************************** 1. row ***************************
Host: %
Db: test
User:
Select_priv: Y
Insert_priv: Y
Update_priv: Y
Delete_priv: Y
Create_priv: Y
Drop_priv: Y
Grant_priv: N
References_priv: Y
Index_priv: Y
Alter_priv: Y
Create_tmp_table_priv: Y
Lock_tables_priv: Y
Create_view_priv: Y
Show_view_priv: Y
Create_routine_priv: Y
Alter_routine_priv: N
Execute_priv: N
*************************** 2. row ***************************
Host: %
Db: test\_%
User:
Select_priv: Y
Insert_priv: Y
Update_priv: Y …Run Code Online (Sandbox Code Playgroud) 我使用 root 帐户创建的帐户'a'@'%'。但是我在指定host参数时无法使用该帐户连接到MySQL服务器。我可以不带-h参数成功连接。请看下面的文字记录。我希望有人能帮我解释一下。谢谢。
mysql> grant all on *.* to 'a'@'%' identified by a;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'a' at line 1
mysql> grant all on *.* to 'a'@'%' identified by 'a';
Query OK, 0 rows affected (0.00 sec)
mysql> show grants for 'a'@'%';
+-----------------------------------------------------------------------------------------------------------+
| Grants for a@% |
+-----------------------------------------------------------------------------------------------------------+
| GRANT …Run Code Online (Sandbox Code Playgroud) 与我的MySQL 问题相关
我在 mysql.user 中有一个具有 USAGE 权限的用户,但在 mysql.db 中该用户具有选择、插入、更新、删除。这样用户就可以成功查询数据库。
我找不到有关此 mysql.db 如何工作的任何信息,是否类似于某种缓存权限?mysqld 重启会刷新它吗?
mysql> show grants for user@'xx.xx.xx.%';
+-------------------------------------------------------------------------------------------------------------------------------+
| Grants for user@xx.xx.xx.% |
+-------------------------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'user'@'xx.xx.xx.%' IDENTIFIED BY PASSWORD 'xxx' REQUIRE SSL |
mysql> select host,db,user, select_priv,update_priv,delete_priv from
mysql.db where user='user';
| host | db | user | select_priv | update_priv | delete_priv |
| xx.xx.xx.1 | myDB | user | Y | Y | Y
Run Code Online (Sandbox Code Playgroud) 我忘记了我为 MySQL 的 root 用户更改的密码。我以 root 用户身份登录,当我这样做
# /opt/lampp/lampp security
时,结果为
XAMPP: Quick security check...
XAMPP: Your XAMPP pages are secured by a password.
XAMPP: Do you want to change the password anyway? [no] n
XAMPP: MySQL has a root passwort set. Fine! :)
XAMPP: The FTP password for user 'nobody' is still set to 'lampp'.
XAMPP: Do you want to change the password? [yes] n
XAMPP: Done.
Run Code Online (Sandbox Code Playgroud)
我如何重置密码。我检查了一下,但在任何文件(包括my.cnf)中都找不到密码。