在 mysql 中授予数据库权限

在 mysql 中授予数据库权限

我有一个新的 mysql 安装,并正在尝试创建一个单独的用户来访问他们自己的数据库。

mysqladmin -u root -p create people
mysql> create user 'cgp'@'localhost' identified by 'myPass';
mysql> grant all on people to 'cgp'@'localhost' identified by 'myPass';
Query OK, 0 rows affected (0.00 sec)       <-- problem here?
mysqladmin -v  -u root -p flush-privileges

mysql -h localhost -u cgp -p people
Enter password:
ERROR 1044 (42000): Access denied for user 'cgp'@'localhost' to database 'people'

mysql -u root -p
mysql> show grants;

GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*xxx' WITH GRANT OPTION
GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION

如您所见,授权表中没有任何针对 cgp 用户的内容。我做错了什么?

答案1

尝试

grant all on people.* to 'cgp'@'localhost' identified by 'myPass';

  • 通配符意味着应该授予人员数据库中所有表的访问权限。

相关内容