我正在阅读 O'Relly “Learning MySQL”,它说您可以通过执行以下操作在 MySQL 中创建一个用户:
mysql> GRANT ALL ON *.* TO 'jill'@'%.invyhome.com' IDENTIFIED BY 'the_password';
Query OK, 0 rows affected (0.01 sec)
Run Code Online (Sandbox Code Playgroud)
但如果我尝试这样做:
-> grant select on testgrounds.personas to ''@'localhost';
--> Error Code: 1133. Can't find any matching row in the user table
Run Code Online (Sandbox Code Playgroud)
但是如果我使用密码它会成功:
->grant select on testgrounds.personas to ''@'localhost' identified by 'pass';
--> 0 row(s) affected
Run Code Online (Sandbox Code Playgroud)
我不得不恢复用户 root 的权限,因为我正在试验并且我把它们搞砸了,所以我想在这样做之前我实际上可以使用书中的语句(我不记得 100%)
-> select current_user;
--> 'root@localhost'
-> show grants;
--> 'GRANT ALL PRIVILEGES ON *.* TO \'root\'@\'localhost\' IDENTIFIED BY …Run Code Online (Sandbox Code Playgroud)