問題描述
我已經創建了數據庫,例如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:授予**所有**數據庫權限的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!