本文共 2696 字,大约阅读时间需要 8 分钟。
mysql用户权限
Let’s see how to grant permissions (called privileges) to a user of the MySQL database
让我们看看如何向MySQL数据库的用户授予权限(称为特权)
By default when you create a new MySQL user using the syntax
默认情况下,当您使用语法创建新MySQL用户时
CREATE USER ''@'localhost' IDENTIFIED BY ' ';
the user cannot do much. We can say that it can’t to anything, actually.
用户不能做太多事情。 我们可以说实际上什么也做不了。
It can’t read data from any existing database, let alone modifying the data. And it can’t even create a new database.
它无法从任何现有数据库读取数据,更不用说修改数据了。 而且它甚至无法创建新的数据库。
To make a user do anything, you have to grant privileges to it.
要使用户执行任何操作,您必须为其授予特权 。
You can do so using the GRANT
command.
您可以使用GRANT
命令执行此操作。
We can use GRANT <permission>
, using the following permission keywords:
我们可以使用GRANT <permission>
,并使用以下权限关键字:
CREATE
CREATE
DROP
DROP
DELETE
DELETE
INSERT
INSERT
SELECT
SELECT
UPDATE
UPDATE
ALL PRIVILEGES
ALL PRIVILEGES
GRANT CREATE ON *.* TO ''@'localhost';
GRANT CREATE ON.* TO ' '@'localhost';
GRANT SELECT ON.* TO ' '@'localhost';
GRANT SELECT ON. '@'localhost'; TO '
GRANT INSERT, UPDATE, DELETE ON.* TO ' '@'localhost';
GRANT DROP ON.* TO ' '@'localhost';
GRANT DROP ON *.* TO ''@'localhost';
GRANT ALL PRIVILEGES ON.* TO ' '@'localhost';
GRANT ALL PRIVILEGES ON *.* TO ''@'localhost';
Example to revoke the DROP
privilege on <database>
:
撤销<database>
上的DROP
特权的示例:
REVOKE DROP ON.* TO ' '@'localhost';
To revoke all privileges, run:
要撤消所有特权,请运行:
REVOKE ALL PRIVILEGES ON *.* TO ''@'localhost';
You can visualize the privileges of a single user by running:
您可以通过运行以下命令来可视化单个用户的特权:
SHOW GRANTS FOR ''@'localhost';
翻译自:
mysql用户权限
转载地址:http://ovqgb.baihongyu.com/