[英]mysql user creation error 42000
I'm trying to create a new user with all privileges, so I tried this code in mysql: 我正在尝试创建一个具有所有特权的新用户,因此我在mysql中尝试了以下代码:
create user 'user'@'localhost' IDENTIFIED BY 'password'
and I got this error 我得到这个错误
-------------- create user 'user'@'localhost' IDENTIFIED BY 'password'
--------------创建用户'user'@'localhost'由'password'标识
ERROR 1227 (42000): Access denied;
错误1227(42000):访问被拒绝; you need (at least one of) the CREATE USER privilege(s) for this operation
您需要(至少其中一个)CREATE USER权限才能进行此操作
Note :I already read this question and the answers (and tried them): 注意:我已经阅读了这个问题和答案(并尝试过):
To see what user you are logged in as: 要查看您以什么身份登录:
SELECT USER();
To see the privileges of the user you are logged in as: 要查看用户的特权,您以以下身份登录:
SHOW GRANTS;
To identify users that have "CREATE USER" privilege: 要标识具有“ CREATE USER”特权的用户:
SELECT u.user, u.host, u.create_user_priv FROM mysql.user u ORDER BY u.user, u.host ;
If DML changes are made to the mysql.user
, mysql.db
et al. 如果对
mysql.user
, mysql.db
等进行了DML更改。 tables, then we can issue this statement to have MySQL re-read the tables to make those changes effective: 表,然后我们可以发出以下语句让MySQL重新读取表以使这些更改生效:
FLUSH PRIVILEGES ;
To a get a CREATE USER
statement executed, we need to be logged in as a user that has the CREATE USER
privilege. 为了执行
CREATE USER
语句,我们需要以具有CREATE USER
特权的用户身份登录。
Or (less desirable) logged in as a user that has sufficient privileges, we can manually issue a DML INSERT
statement to add a new row to mysql.user
table, and then run the FLUSH PRIVILEGES
statement. 或(不太理想)以具有足够特权的用户身份登录,我们可以手动发出DML
INSERT
语句以将新行添加到mysql.user
表中,然后运行FLUSH PRIVILEGES
语句。
Or (as a last resort), if we don't have login credentials for any suitable user, we can get MySQL restarted with the --skip-grant-tables
option, and then make changes to the mysql.user
table (using DML INSERT and/or UPDATE statements), and then restart MySQL again (this time without the --skip-grant-tables
option.) 或者(作为最后的手段),如果我们没有任何合适用户的登录凭据,则可以使用
--skip-grant-tables
选项重新启动MySQL,然后对mysql.user
表进行更改(使用DML) INSERT和/或UPDATE语句),然后再次重新启动MySQL(这次没有--skip-grant-tables
选项。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.