From: http://m.blog.csdn.net/blog/langkeziju/13511411
我的MySQL版本為5.6.14版本,是二進制包安裝的(雖然是二進制包安裝的,但是以下問題同樣適用於源碼安裝包安裝的MySQL)
今天在我的測試庫上添加一個新用戶,報錯:
[mysql@ydrh2 ~]$ mysql -uroot -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即可