MySQL 1142 错误,但用户名为空:SELECT 命令被拒绝给用户 ''@'%' for table `tablename'

问题描述 投票:0回答:1

当用户名为空并出现以下典型错误时,这意味着什么:

用户 ''@'%' 对于表 `tablename' 的 SELECT 命令被拒绝

为什么不指定当前登录的用户名?

mariadb
1个回答
0
投票

如果您使用空用户名创建用户,通常会发生这种情况:

$> mysql -unonexisting -e"select * from test.t1";
ERROR 1045 (28000): Access denied for user 'nonexisting'@'localhost' (using password: NO)

$> mysql -uroot -e"CREATE USER ''@'%'"

$> $mysql -unonexisting -e"select * from test.t1";
ERROR 1142 (42000) at line 1: SELECT command denied to user ''@'localhost' for table `test`.`t1`

因此只需删除用户名为空的用户即可。

© www.soinside.com 2019 - 2024. All rights reserved.