出现Field 'ssl_cipher' doesn't have a default value错误怎么解决

时间:2021-11-19 08:21:31

创建snort数据库,创建snort用户,将snort库所有表的所有权限赋予用户snort。

mysql> create database snort;
Query OK, 1 row affected (0.06 sec)
创建数据库

mysql> create user snort;
Query OK, 1 row affected (0.06 sec)
创建用户snort


mysql> use mysql;
进入mysql库
mysql> insert into user (Host,User,Password) values ("localhost","snort",PASSWORD("112233445566"));
创建用户,设置初始密码(这样做不行,会报标题上的错误)

mysql> update user set Password values PASSWORD("112233445566") where user='snort';
将已经建好的用户,设置初始密码

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
使改动生效;注:如果不执行该指令,则无法正常执行后续指令。
mysql> grant all on snort.* to 'snort'@'localhost' ;
Query OK, 0 rows affected (0.00 sec)
将snort库的所有权限赋予 snort用户
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
使改动生效
mysql> show grants for snort@localhost;
+-------------------------------------------------------------------------------------+
| Grants for snort@localhost |
+-------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'snort'@'localhost' IDENTIFIED BY PASSWORD '1e6b29186dd45e97' |
| GRANT ALL PRIVILEGES ON `snort`.* TO 'snort'@'localhost' |
+-------------------------------------------------------------------------------------+






本文向大家讲解的是Mysql添加用户错误:ERROR 1364 (HY000): Field 'ssl_cipher' doesn't have a default value解决方法,感兴趣的同学参考下。

错误描述:

添加用户 insert into mysql.user(Host,User,Password) values("localhost","test",password("1234"));

报以下的错误 ERROR 1364 (HY000): Field 'ssl_cipher' doesn't have a default value错误

mysql5.1以上版本,我是在5.6版本上操作的。

语原因:

mysql用户表的中某些字段不能为空,没有默认值,其实是操作错误,mysql添加用户是不能这样直接insert user表的。

解决方法:

正确的添加用户方法:

GRANT USAGE ON *.* TO 'user01'@'localhost' IDENTIFIED BY '123456' WITH GRANT OPTION;

用户:user01,密码:123456,这样就添加了一个新的用户,不会出以上的错误了。