When creating a user in mysql today, you can see how to insert data directly into the User table when someone is using it, as follows:
mysql> insert into mysql.user(Host,User,Password) values("localhost","test",password("1234"));
So I also tried to create users with this method in the database, but got the following error:
mysql> insert into mysql.user(Host,User,Password) values('localhost','siu',password('siu'));
ERROR 1364 (HY000): Field 'ssl_cipher' doesn't have a default value
The reason for this error is that mysql’s default configuration is strict mode, which prohibits adding new users by directly modifying the USER table in the mysql library by INSERT.
solution is to modify my. Ini (Windows system) or my. Conf (Linux system) configuration file, taking Linux system as an example:
sql-mode=STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
Modified to:
sql-mode=NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
Then restart the mysql service
service mysql restart
Create the user again and it will be successful
mysql> insert into mysql.user(Host,User,Password) values("localhost","joey",password("1234"));
Query OK, 1 row affected, 3 warnings (0.00 sec)
It is important to note, however, that since mysql by default forbids this method to create users for database security, we should also avoid creating users by inserting. The correct way to create a user is:
mysql> create user 'joey'@'localhost' identified by 'joey';
Query OK, 0 rows affected (0.00 sec)
This user is then authorized for certain databases:
grant all privileges on joey.* to 'joey'@'localhost' identified by 'joey';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
Read More:
- Error: field * doesn’t have a default value
- Mybatis error “field ‘ID’ doesn’t have a default value”
- Get the default value of the field
- In SQLite database, set the default value for the field as the current time
- PostgreSQL sets the default value of the field to the current year
- [MySQL] error 1396 (HY000): Operation create user failed for ‘MySQL’ @’localhost ‘
- ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
- Use xx [‘xx ‘] = XX to set field value or does not support field: XXX
- Linux (error 1819 (HY000): your password does not satisfy the current policy requirements)
- The fastest way to solve the problem of error reporting from crypto.cipher import AES
- MySQL ERROR 1054 (42S22): Unknown column’password’ in’field list’ error
- MySQL:ERROR 1067 (42000): Invalid default value for ‘end_time’
- Linux-mysql8.0 password reset problem – error 1396 (HY000): Operation alter user failed for ‘root’ @’localhost ‘
- MySQL – ERROR 1146 (42S02): Table ‘mysql.user’ doesn’t exist
- MySQL password setting error message: error 1054 (42s22): unknown column ‘password’ in ‘field list’
- Mysql start slave error 1201 (HY000)
- Error 1396 (HY000): Operation create user failed for ‘xxx’ @’xxx ‘
- Error 1136 (21s01): column count doesn’t match value count at row 1
- MYSQL:ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
- ERROR 2002 (HY000): Can’t connect to MySQL server on ‘localhost’ (10061)