mysql8.0 new user and password encryption rule changes

MySQL8.0 GA version has been released, the current latest version 8.0.12 GA. Although compared to previous versions, MySQL8.0 no new elements, but, after refactoring, MySQL8.0 optimizer more powerful, but also has some new features, such as support for indexing or hidden.

However, MySQL version, there are many new and previous versions not the same place, for example, there are many changes in user created.

 

1. The user creates

 Create a user to create a user's operation has no way to support grant at the same time, you must first create a user re-authorization

Copy the code
mysql> grant all on *.* to 'admin'@'%' identified by 'admin123';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'identified by 'admin123'' at line 1
mysql> create user  'admin'@'%' identified by 'admin123';
Query OK, 0 rows affected (0.06 sec)

mysql> grant all on *.* to 'admin'@'%' ;
Query OK, 0 rows affected (0.04 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
Copy the code

 

 2. User 1

When the user login password contains special symbols outside of the letters or numbers, the original use double or single quotes are logged in, but are having trouble mysql8.0 log in below

Copy the code
[root@gjc18 lib]# /usr/local/mysql8.0/bin/mysql -uroot -p"root!@#123" --socket=/data/mysql/mysql3310/tmp/mysql3310.sock
-bash: !@#123": event not found
[root@gjc18 lib]# /usr/local/mysql8.0/bin/mysql -uroot -p'root!@#123' --socket=/data/mysql/mysql3310/tmp/mysql3310.sock
mysql: [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 22
Server version: 8.0.12 MySQL Community Server - GPL
Copy the code

3. Low version of the client to log anomaly

 Error Number 2058: Plugin caching_sha2_password could not be loaded

This occurs because previous versions mysql8.0 encryption rule is mysql_native_password, and after mysql8, encryption rules are caching_sha2_password, to solve this problem in two ways, one is to upgrade the client-driven, one is the mysql user password encryption rule reduced to mysql_native_password.

Modifying the user password encryption rules can be used in the following manner:

1) modify the encryption method:

Copy the code
- but for the use of a password to modify 
MySQL> the ALTER the USER 'the root' @ '%' the IDENTIFIED BY 'password' PASSWORD the EXPIRE NEVER; 
Query the OK, 0 rows affected (0.02 sec) 

- Change password and specifies an encryption rule for mysql_native_password 
MySQL> the USER the ALTER 'the root' @ '%' the WITH mysql_native_password the IDENTIFIED BY '123456'; 
Query the OK, 0 rows affected (0.01 sec) 

- refresh permissions 
MySQL> the flush privileges; 
Query the OK, 0 rows affected (0.01 sec) 

MySQL>
Copy the code

After modification can successfully log on again

 

 

2) Use high version of the client

This situation can also occur linux-level clients at login, so the need to use high version of the client

Copy the code
[root@gjc18 lib]# mysql -uroot -p'123456' --socket=/data/mysql/mysql3310/tmp/mysql3310.sock
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2059 (HY000): Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/local/mysql/lib/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory
[root@gjc18 lib]# /usr/local/mysql8.0/bin/mysql -uroot -p'123456' --socket=/data/mysql/mysql3310/tmp/mysql3310.sock
mysql: [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 26
Server version: 8.0.12 MySQL Community Server - GPL

Copyright (c) 2000, 2018, 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.
Copy the code

 

In addition to password plug adjustment, MySQL8.0 several other major new password policy are:

  • Support password expiration policy, you need to change your password periodically
  • Increase the password history checking mechanism to prevent the same password in recent times (times can be configured)
  • Modify password is required to verify the old password, to prevent the risk of tampering
  • It supports dual-password mechanism, the new password and the old password before the modification can be used simultaneously, and you can choose to use a master password or a second password
  • Increasing constraint password strength, avoid the use of weak passwords

 

 

 

Geng Kitchen has opened a personal micro-channel public number, or would like further communication would like to know other students can follow my articles

Guess you like

Origin www.cnblogs.com/huakai201/p/11470565.html