MySQL New Features - Accounts and Security

1. User creation and authorization

In MySQL8, user creation and authorization statements must be executed separately, and previous versions can be executed together.

MySQL8 version

grant all privileges on *.* to 'lijin'@'%' identified by 'Lijin@2022';

create user 'lijin'@'%' identified by 'Lijin@2022';
grant all privileges on *.* to 'lijin'@'%';

MySQL5.7 version

grant all privileges on *.* to 'lijin'@'%' identified by 'Lijin@2022';

2. Authentication plug-in update

The default authentication plugin in MySQL 8.0 is caching_sha2_password, which replaces the previous mysql_native_password.

show variables like 'default_authentication%';

version 5.7

8 version

select user, host,plugin from mysql.user;

The problem with this is that if the client is not updated, it will not be able to connect! !

Of course, you can find the my.cnf file on the MySQL server and modify the relevant parameters (but it will take effect after restarting MySQL)

If there is no way to restart the service, there is another dynamic way:

alter user 'lijin'@'%' identified with mysql_native_password by 'Lijin@2022';
select host,user from mysql.user;

It can also be accessed using the old Navicat for MySQL

3. Password management

MySQL 8.0 began to allow restrictions on the reuse of previous passwords (when changing passwords).

And also added the password modification management function

show variables like 'password%';

Modify policy (global level)

set persist password_history=3;        --修改密码不能和最近3次一致

Modify Policy (User Level)

alter user 'lijin'@'%' password history 3;
select user, host,Password_reuse_history from mysql.user;

Use repeated passwords to modify user passwords (specify lijin users)

alter user 'lijin'@'%' identified by 'Lijin@2022';

If we change the global parameter to 0, the root user can change the password repeatedly

alter user 'root'@'localhost' identified by '789456';

password_reuse_interval is limited according to the number of days (repeat is not allowed)

password_require_current Whether to verify the old password (off no verification, on verification) (for non-root users)

set persist password_require_current=on;

Guess you like

Origin blog.csdn.net/m0_70299172/article/details/130496151