今天第一次把玩mysql,在默认数据库mysql中创建用户时报错:
ERROR 1364 (HY000): Field 'ssl_cipher' doesn't have a default value
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> SELECT host, user, password FROM user WHERE user = 'guest';
Empty set (0.23 sec)
mysql> INSERT INTO user
-> (host, user, password,
-> select_priv, insert_priv, update_priv)
-> VALUES ('localhost', 'scofy',
-> PASSWORD('mysql'), 'Y', 'Y', 'Y');
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即可
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,
-> select_priv, insert_priv, update_priv)
-> VALUES ('localhost', 'scofy',
-> PASSWORD('mysql'), 'Y', 'Y', 'Y');
Query OK, 1 row affected, 3 warnings (0.00 sec)
mysql> SELECT host, user, password FROM user WHERE user = 'scofy';
+-----------+-------+-------------------------------------------+
| host | user | password |
+-----------+-------+-------------------------------------------+
| localhost | scofy | *E74858DB86EBA20BC33D0AECAE8A8108C56B17FA |
+-----------+-------+-------------------------------------------+
1 row in set (0.01 sec)