问题描述
我正在尝试执行此查询-
I am trying to execute this queries -
DROP DATABASE IF EXISTS `hotel`;
GRANT USAGE ON *.* TO 'user'@'localhost';
DROP USER 'user'@'localhost';
CREATE USER user@localhost IDENTIFIED BY 'user';
CREATE DATABASE `hotel`
CHARACTER SET 'utf8'
COLLATE 'utf8_general_ci';
GRANT USAGE ON *.* to 'user'@'localhost' identified by 'user';
但是我总是在
GRANT USAGE ON *.* TO 'user'@'localhost' Error Code: 1133. Can't find any matching row in the user table 0.000 sec
我认为Grant usage
如果用户不存在,则创建新用户.怎么了?
I thought that Grant usage
create new user if user does not exist. What is wrong?
推荐答案
在以前的mysql版本中就是这种情况.如果您想采用新方法,请参见此答案.如果您想修改系统设置以使其像以前一样工作,请继续阅读.但是,请注意,这是不推荐使用的行为,因为链接的文档指出
In previous versions of mysql that was the case. See this answer if you want to do it the new way. If you would like to modify your system settings to make it work the way it used to, read on. However, note that this is a deprecated behavior, as the linked documentation states that
从文档中,您可以设置一个选项,以允许mysql创建用户(如果不存在).
From the documentation, you can set an option to allow mysql to create a user if it does not exist.
防止GRANT语句在以下情况下自动创建新用户: 否则会这样做,除非非空密码也为 指定.
Prevent the GRANT statement from automatically creating new users if it would otherwise do so, unless a nonempty password also is specified.
要设置选项:
这篇关于在用户表中找不到任何匹配的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!