MySQL:授予对数据库的**所有**权限

MySQL: Grant **all** privileges on database(MySQL:授予对数据库的**所有**权限)
本文介绍了MySQL:授予对数据库的**所有**权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了数据库,例如mydb".

I've created database, for example 'mydb'.

CREATE DATABASE mydb CHARACTER SET utf8 COLLATE utf8_bin;
CREATE USER 'myuser'@'%' IDENTIFIED BY PASSWORD '*HASH';
GRANT ALL ON mydb.* TO 'myuser'@'%';
GRANT ALL ON mydb TO 'myuser'@'%';
GRANT CREATE ON mydb TO 'myuser'@'%';
FLUSH PRIVILEGES;

现在我可以从任何地方登录数据库,但不能创建表.

Now i can login to database from everywhere, but can't create tables.

如何授予该数据库和(将来)表的所有权限.我无法在mydb"数据库中创建表.我总是得到:

How to grant all privileges on that database and (in the future) tables. I can't create tables in 'mydb' database. I always get:

CREATE TABLE t (c CHAR(20) CHARACTER SET utf8 COLLATE utf8_bin);
ERROR 1142 (42000): CREATE command denied to user 'myuser'@'...' for table 't'

推荐答案

GRANT ALL PRIVILEGES ON mydb.* TO 'myuser'@'%' WITH GRANT OPTION;

这就是我创建超级用户"的方式.特权(虽然我通常会指定一个主机).

This is how I create my "Super User" privileges (although I would normally specify a host).

虽然这个答案可以解决访问问题,但 WITH GRANT OPTION 会创建一个 MySQL 用户,该用户可以 编辑其他用户的权限.

While this answer can solve the problem of access, WITH GRANT OPTION creates a MySQL user that can edit the permissions of other users.

GRANT OPTION 权限使您可以将自己拥有的权限授予其他用户或从其他用户删除.

The GRANT OPTION privilege enables you to give to other users or remove from other users those privileges that you yourself possess.

出于安全原因,您不应将此类用户帐户用于公众可以访问的任何流程(即网站).建议您创建一个仅具有数据库权限的用户用于此类用途.

For security reasons, you should not use this type of user account for any process that the public will have access to (i.e. a website). It is recommended that you create a user with only database privileges for that kind of use.

这篇关于MySQL:授予对数据库的**所有**权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Hibernate reactive No Vert.x context active in aws rds(AWS RDS中的休眠反应性非Vert.x上下文处于活动状态)
Bulk insert with mysql2 and NodeJs throws 500(使用mysql2和NodeJS的大容量插入抛出500)
Flask + PyMySQL giving error no attribute #39;settimeout#39;(FlASK+PyMySQL给出错误,没有属性#39;setTimeout#39;)
auto_increment column for a group of rows?(一组行的AUTO_INCREMENT列?)
Sort by ID DESC(按ID代码排序)
SQL/MySQL: split a quantity value into multiple rows by date(SQL/MySQL:按日期将数量值拆分为多行)