这篇文章主要讲解了“MySQL5.6添加root用户报错:Field 'ssl_cipher' doesn't have a default value怎么解决”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“MySQL5.6添加root用户报错:Field 'ssl_cipher' doesn't have a default value怎么解决”吧!
2012.14.15
MySQL: 5.6.19
刚刚忙完了零售测试环境的部署,现在处理上周遗留的问题。
由于user 表中确实localhost和127.0.0.1条目信息:
-
mysql> select Host,User,Password from user where User=\'root\';
-
+————–+——+——————————————-+
-
| Host | User | Password |
-
+————–+——+——————————————-+
-
| bidevedw\\_db| root | *D013A4E3A5BB01E4239D18D7E93B59B7D2B767AD |
-
| ::1 | root | *D013A4E3A5BB01E4239D18D7E93B59B7D2B767AD |
-
| % | root | *D013A4E3A5BB01E4239D18D7E93B59B7D2B767AD |
-
+————–+——+——————————————-+-
这样导致我在服务器本地登录的时候,解析的是以root@'%' 方式登录,然而这种方式登录的root是没有grant 权限,这使得不能给其他用户授权。
-
*************************** 4. row ***************************
-
Host: %
-
User: root
-
Password: *D013A4E3A5BB01E4239D18D7E93B59B7D2B767AD
-
Select_priv: Y
-
Insert_priv: Y
-
Update_priv: Y
-
Delete_priv: Y
-
Create_priv: Y
-
Drop_priv: Y
-
Reload_priv: Y
-
Shutdown_priv: Y
-
Process_priv: Y
-
File_priv: Y
-
Grant_priv: N
-
References_priv: Y
-
Index_priv: Y
-
Alter_priv: Y
-
Show_db_priv: Y
-
Super_priv: Y
-
Create_tmp_table_priv: Y
-
Lock_tables_priv: Y
-
Execute_priv: Y
-
Repl_slave_priv: Y
-
Repl_client_priv: Y
-
Create_view_priv: Y
-
Show_view_priv: Y
-
Create_routine_priv: Y
-
Alter_routine_priv: Y
-
Create_user_priv: Y
-
Event_priv: Y
-
Trigger_priv: Y
-
Create_tablespace_priv: Y
-
ssl_type:
-
ssl_cipher:
-
x509_issuer:
-
x509_subject:
-
max_questions: 0
-
max_updates: 0
-
max_connections: 0
-
max_user_connections: 0
-
plugin: mysql_native_password
-
authentication_string:
-
password_expired: N
解决思路分析:
把缺失的条目添加到user表中。
由于我也是这半年才真正的接触MySQL。所以很多也是问度娘,我也以为像user表中添加记录是使用INSERT into。但是这种方法会报错:
ERROR 1364 (HY000): Field 'ssl_cipher' doesn't have a default value
这是因为user表中有几个列是非空,而它的默认值是null .
| ssl_cipher | blob | NO | | NULL | |
| x509_issuer | blob | NO | | NULL | |
| x509_subject | blob | NO | | NULL | |
所以一般的insert into 都是给出前三列。而忽视了其他列。这种方式好像是在5.1之前可以使用的。我的是5.6。这种方式就行不通
解决方法:
GRANT USAGE ON *.* TO 'root'@'localhost' IDENTIFIED BY '123456' WITH GRANT OPTION;
GRANT USAGE ON *.* TO 'root'@'l127.0.0.1' IDENTIFIED BY '123456' WITH GRANT OPTION;
记得要刷新一下:flush privileges;
重新登录mysql -uroot -p123456
查看当前登录用户和登录的方式:
mysql> select user();
+—————-+
| user() |
+—————-+
| root@localhost |
+—————-+
1 row in set (0.00 sec)
这样就可以不走@'%'
还可以修改root @'%'方式的权限:
mysql> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "123456" WITH GRANT OPTION;
Query OK, 0 rows affected (0.02 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.03 sec)
你权限的时候会显示:Grant_priv: Y
这样root用户以@'%'方式就可以做grant操作
感谢各位的阅读,以上就是“MySQL5.6添加root用户报错:Field 'ssl_cipher' doesn't have a default value怎么解决”的内容了,经过本文的学习后,相信大家对MySQL5.6添加root用户报错:Field 'ssl_cipher' doesn't have a default value怎么解决这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是云搜网,小编将为大家推送更多相关知识点的文章,欢迎关注!