[mysql]ERROR 1364 (HY000): Field 'ssl_cipher' doesn't have a default value

本文介绍在MySQL5.6.14版本中遇到的添加新用户时报错ERROR1364(HY000): Field 'ssl_cipher' doesn't have a default value的问题及解决方法。在严格模式下,尝试直接插入数据到mysql.user表会触发此错误。解决方式是修改my.cnf中的sql_mode设置,移除STRICT_TRANS_TABLES选项并重启MySQL服务。

[mysql]ERROR 1364 (HY000): Field 'ssl_cipher' doesn't have a default value

From: http://m.blog.youkuaiyun.com/blog/langkeziju/13511411

我的MySQL版本为5.6.14版本,是二进制包安装的(虽然是二进制包安装的,但是以下问题同样适用于源码安装包安装的MySQL)

今天在我的测试库上添加一个新用户,报错:

 

[mysql@ydrh2 ~]$ mysql -u root -p123456
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.14-enterprise-commercial-advanced MySQL Enterprise Server - Advanced Edition (Commercial)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> insert into user(host,user,password) values("localhost","peter1",password("123456"));
ERROR 1046 (3D000): No database selected
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> insert into user(host,user,password) values("localhost","peter1",password("123456"));
ERROR 1364 (HY000): Field 'ssl_cipher' doesn't have a default value

 

原因:在我的配置文件my.cnf中有这样一条语句

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

指定了严格模式,为了安全,严格模式禁止通过insert 这种形式直接修改mysql库中的user表进行添加新用户

 

解决办法:

将配置文件中的STRICT_TRANS_TABLES删掉,即改为:

sql_mode=NO_ENGINE_SUBSTITUTION

然后重启mysql即可

我只想解决我的问题[root@master hive]# [root@master hive]# pkill mysqld [2]- 退出 1 nohup /export/server/hive/bin/hive --service metastore > /export/server/hive/logs/metastore.log 2>&1 [root@master hive]# pkill mysqld_safe [root@master hive]# 2025-11-26T15:10:03.340710Z mysqld_safe mysqld from pid file /export/server/mysql/mysql.pid ended [1]- 完成 mysqld_safe --skip-grant-tables --skip-networking [root@master hive]# [root@master hive]# ps aux | grep mysql root 23564 0.0 0.2 112824 972 pts/4 S+ 23:10 0:00 grep --color=auto mysql [root@master hive]# /export/server/mysql/bin/mysqld_safe --skip-grant-tables --skip-networking --basedir=/export/server/mysql --datadir=/export/server/mysql/data & [4] 23768 [root@master hive]# 2025-11-26T15:10:40.688895Z mysqld_safe Logging to '/export/server/mysql/data/error.log'. 2025-11-26T15:10:40.744255Z mysqld_safe Starting mysqld daemon with databases from /export/server/mysql/data [root@master hive]# ps aux | grep mysqld root 23768 0.2 0.0 113412 76 pts/4 S 23:10 0:00 /bin/sh /export/server/mysql/bin/mysqld_safe --skip-grant-tables --skip-networking --basedir=/export/server/mysql --datadir=/export/server/mysql/data mysql 24013 8.7 23.5 1120852 113112 pts/4 Sl 23:10 0:02 /export/server/mysql/bin/mysqld --basedir=/export/server/mysql --datadir=/export/server/mysql/data --plugin-dir=/export/server/mysql/lib/plugin --user=mysql --skip-grant-tables --skip-networking --log-error=/export/server/mysql/data/error.log --pid-file=/export/server/mysql/mysql.pid --socket=/tmp/mysql.sock --port=3306 root 24658 0.0 0.2 112824 976 pts/4 S+ 23:11 0:00 grep --color=auto mysqld [root@master hive]# mysql -u root Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.43 MySQL Community Server (GPL) Copyright (c) 2000, 2023, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.17 sec) mysql> UPDATE mysql.user SET -> authentication_string = PASSWORD('123456'), -> plugin = 'mysql_native_password' -> WHERE User = 'root'; Query OK, 0 rows affected, 1 warning (0.04 sec) Rows matched: 1 Changed: 0 Warnings: 1 mysql> -- 插入或更新远程访问权限 mysql> INSERT INTO mysql.user (Host, User, Select_priv, Insert_priv, Update_priv, Delete_priv, Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv, File_priv, Grant_priv, References_priv, Index_priv, Alter_priv, Show_db_priv, Super_priv, Create_tmp_table_priv, Lock_tables_priv, Execute_priv, Repl_slave_priv, Repl_client_priv, Create_view_priv, Show_view_priv, Create_routine_priv, Alter_routine_priv, Create_user_priv, Event_priv, Trigger_priv, Create_tablespace_priv) -> VALUES ('%', 'root', 'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y') -> ON DUPLICATE KEY UPDATE -> Select_priv='Y', Insert_priv='Y', Update_priv='Y', Delete_priv='Y', -> Create_priv='Y', Drop_priv='Y', Grant_priv='Y', Super_priv='Y'; ERROR 1364 (HY000): Field 'ssl_cipher' doesn't have a default value mysql> mysql> -- 同样设置 localhost 和 master 主机 mysql> UPDATE mysql.user SET Host='localhost' WHERE User='root' AND Host='127.0.0.1'; Query OK, 0 rows affected (0.04 sec) Rows matched: 0 Changed: 0 Warnings: 0 mysql> INSERT INTO mysql.user (Host, User, Select_priv, Insert_priv, Update_priv, Delete_priv, Create_priv, Drop_priv, Grant_priv, Super_priv) VALUES ('master', 'root', 'Y','Y','Y','Y','Y','Y','Y','Y') ON DUPLICATE KEY UPDATE Select_priv='Y'; ERROR 1364 (HY000): Field 'ssl_cipher' doesn't have a default value mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.05 sec) mysql> EXIT; Bye [root@master hive]# pkill mysqld [root@master hive]# pkill mysqld_safe [root@master hive]# 2025-11-26T15:12:09.597886Z mysqld_safe mysqld from pid file /export/server/mysql/mysql.pid ended [4]+ 完成 /export/server/mysql/bin/mysqld_safe --skip-grant-tables --skip-networking --basedir=/export/server/mysql --datadir=/export/server/mysql/data [root@master hive]# # 查看端口监听情况 [root@master hive]# netstat -tuln | grep 3306 [root@master hive]# /export/server/mysql/bin/mysqld_safe --basedir=/export/server/mysql --datadir=/export/server/mysql/data & [4] 26408 [root@master hive]# 2025-11-26T15:12:23.844308Z mysqld_safe Logging to '/export/server/mysql/data/error.log'. 2025-11-26T15:12:23.902108Z mysqld_safe Starting mysqld daemon with databases from /export/server/mysql/data [root@master hive]# # 查看端口监听情况 [root@master hive]# netstat -tuln | grep 3306 tcp6 0 0 :::3306 :::* LISTEN [root@master hive]# mysql -h 192.168.161.130 -u root -p -e "SHOW DATABASES;" Enter password: ERROR 1045 (28000): Access denied for user 'root'@'master' (using password: YES) [root@master hive]# mysql -u root -p -e " > DROP DATABASE IF EXISTS hive; > CREATE DATABASE hive CHARACTER SET utf8 COLLATE utf8_general_ci; > GRANT ALL PRIVILEGES ON hive.* TO 'root'@'%' IDENTIFIED BY '123456'; > GRANT ALL PRIVILEGES ON hive.* TO 'root'@'master' IDENTIFIED BY '123456'; > GRANT ALL PRIVILEGES ON hive.* TO 'root'@'localhost' IDENTIFIED BY '123456'; > FLUSH PRIVILEGES; > " Enter password: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) [root@master hive]# cd /export/server/hive [root@master hive]# bin/schematool -dbType mysql -initSchema -verbose SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/export/server/hive/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/root/export/server/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory] Metastore connection URL: jdbc:mysql://192.168.161.130:3306/hive?createDatabaseIfNotExist=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8 Metastore Connection Driver : com.mysql.jdbc.Driver Metastore connection User: root org.apache.hadoop.hive.metastore.HiveMetaException: Failed to get schema version. Underlying cause: java.sql.SQLException : Access denied for user 'root'@'master' (using password: YES) SQL Error code: 1045 org.apache.hadoop.hive.metastore.HiveMetaException: Failed to get schema version. at org.apache.hadoop.hive.metastore.tools.HiveSchemaHelper.getConnectionToMetastore(HiveSchemaHelper.java:94) at org.apache.hive.beeline.HiveSchemaTool.getConnectionToMetastore(HiveSchemaTool.java:169) at org.apache.hive.beeline.HiveSchemaTool.testConnectionToMetastore(HiveSchemaTool.java:475) at org.apache.hive.beeline.HiveSchemaTool.doInit(HiveSchemaTool.java:581) at org.apache.hive.beeline.HiveSchemaTool.doInit(HiveSchemaTool.java:567) at org.apache.hive.beeline.HiveSchemaTool.main(HiveSchemaTool.java:1517) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.hadoop.util.RunJar.run(RunJar.java:318) at org.apache.hadoop.util.RunJar.main(RunJar.java:232) Caused by: java.sql.SQLException: Access denied for user 'root'@'master' (using password: YES) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:965) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3933) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3869) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:864) at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1707) at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1217) at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2189) at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2220) at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2015) at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:768) at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at com.mysql.jdbc.Util.handleNewInstance(Util.java:403) at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:385) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:323) at java.sql.DriverManager.getConnection(DriverManager.java:664) at java.sql.DriverManager.getConnection(DriverManager.java:247) at org.apache.hadoop.hive.metastore.tools.HiveSchemaHelper.getConnectionToMetastore(HiveSchemaHelper.java:88) ... 11 more *** schemaTool failed *** [root@master hive]#
最新发布
11-27
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值