在用户表中找不到任何匹配的行 [英] Can't find any matching row in the user table

查看:212
本文介绍了在用户表中找不到任何匹配的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试执行此查询-

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?

推荐答案

我认为,如果用户不存在,则Grant用法会创建新用户.怎么了?

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

NO_AUTO_CREATE_USER将在以后的MySQL中删除 发布,此时将在以下位置启用其效果 所有时间(GRANT不会创建帐户)

NO_AUTO_CREATE_USER will be removed in a future MySQL release, at which point its effect will be enabled at all times (GRANT will not create accounts)

文档中,您可以设置一个选项,以允许mysql创建用户(如果不存在).

From the documentation, you can set an option to allow mysql to create a user if it does not exist.

NO_AUTO_CREATE_USER

NO_AUTO_CREATE_USER

防止GRANT语句在以下情况下自动创建新用户: 否则会这样做,除非非空密码也为 指定.

Prevent the GRANT statement from automatically creating new users if it would otherwise do so, unless a nonempty password also is specified.

要设置选项:

您可以在运行时通过使用SET [GLOBAL | SESSION]更改SQL模式. sql_mode ='modes'语句来设置sql_mode系统值.

You can change the SQL mode at runtime by using a SET [GLOBAL|SESSION] sql_mode='modes' statement to set the sql_mode system value.

这篇关于在用户表中找不到任何匹配的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆