MySQL 错误 1364:1364:字段 'ssl_cipher' 没有默认值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18523861/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 18:42:14  来源:igfitidea点击:

ERROR 1364: 1364: Field 'ssl_cipher' doesn't have a default value

mysqlinsert

提问by Eae

ERROR 1364: 1364: Field 'ssl_cipher' doesn't have a default value .

SQL Statement:

SQL语句:

INSERT INTO `samedaycrm4`.`users` (`Host`, `User`, `Password`) VALUES ('%', 'Bonnie', '*BB71B8925EED8E5387A872A38E566BFCB0F78071')

I am trying to determine the cause of the error ERROR 1364: 1364: Field 'ssl_cipher' doesn't have a default value..?

我正在尝试确定错误 ERROR 1364: 1364: Field 'ssl_cipher' 没有默认值的原因..?

Thanks in advance...

提前致谢...

采纳答案by Eae

The ssl_ciphercolumn in your table has been marked non-null, but your INSERTquery isn't providing a value for it. MySQL will try to assign the default value in these circumstances, but your column hasn't been given one.

ssl_cipher表中的列已标记为non-null,但您的INSERT查询未为其提供值。MySQL 将尝试在这些情况下分配默认值,但您的列尚未指定。

You need either to set a default value for ssl_cipher, or alter the table such that the ssl_cipheris not marked as non-null

您需要为 设置默认值ssl_cipher,或者更改表以使ssl_cipher不被标记为non-null

回答by Uday Hiwarale

//This happens due to the internal structure of user table in mysql database (mysql.user) has many column of administrative privileges which accept 'N' or 'Y' value but not NULL Value. Not assigning these values in user addition syntax by INSERT method will provide null values to table and hence error 1364 occur. //instead using GRANT syntax will give no administrative privileges to user mysql>use mysql;

//出现这种情况是因为mysql数据库(mysql.user)中用户表的内部结构有很多管理权限列,接受'N'或'Y'值但不接受NULL值。不通过 INSERT 方法在用户添加语法中分配这些值将为表提供空值,因此会发生错误 1364。//相反,使用 GRANT 语法不会给用户 mysql>use mysql 任何管理权限;

mysql> GRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE
       -> ON database.*  //for all tables in DATABASE database
       -> TO 'user'@'localhost'
       -> IDENTIFIED BY 'password';

//user will get created

//用户将被创建

回答by Sagar Mahewar

FYI check comment from "Sergei Golubchik" at https://bugs.mysql.com/bug.php?id=14579

仅供参考,在https://bugs.mysql.com/bug.php?id=14579 上查看“Sergei Golubchik”的评论

[ It doesn't look like a bug to me. INSERT INTO mysql.user is deprecated since 3.23 - one should use GRANT or CREATE USER to add new users. As for the GRANT failing on Windows, it's a duplicate of the BUG#13989, which is "Not a bug" either. GRANT fails because on Windows, installer adds the following line to my.ini sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" which prevents GRANT from auto-creating users.]

[对我来说,这看起来不像是一个错误。INSERT INTO mysql.user 自 3.23 起已弃用 - 应使用 GRANT 或 CREATE USER 添加新用户。至于 Windows 上的 GRANT 失败,它是 BUG#13989 的副本,也不是“错误”。GRANT 失败,因为在 Windows 上,安装程序将以下行添加到 my.ini sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" 以防止 GRANT 自动创建用户。]

And finally the implementation for CREATE USER, you can find at -

最后是 CREATE USER 的实现,你可以在 -

https://dev.mysql.com/doc/refman/5.7/en/adding-users.html

https://dev.mysql.com/doc/refman/5.7/en/adding-users.html

It should solve your problem, using "CREATE USER" approach.

它应该使用“创建用户”方法解决您的问题。