当用户名为空并出现以下典型错误时,这意味着什么:
用户 ''@'%' 对于表 `tablename' 的 SELECT 命令被拒绝
为什么不指定当前登录的用户名?
如果您使用空用户名创建用户,通常会发生这种情况:
$> 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`
因此只需删除用户名为空的用户即可。