MySQL 8.0.18 adds authentication plug-in-Unix So
The unix_socket authentication plug-in allows users to use the operating system's credentials when connecting to MariaDB through a local Unix socket file.
Popular is to use the account of the Linux operating system to log in to the MariaDB/MySQL database.
This feature was added in MariaDB 10.4.6 and is currently supported in MySQL 8.0.18.
Usage:
1. Install the plug-in
Mysql > INSTALL PLUGIN auth_socket SONAME 'auth_socket.so';Query OK, 0 rows affected (0.01 sec)
2. Create a database account hechunyang
Mysql > CREATE USER 'hechunyang'@'localhost' IDENTIFIED WITH auth_socket;Query OK, 0 rows affected (0.00 sec)
3. Create an operating system account hechunyang
# useradd hechunyang
# passwd hechunyang
Log in to the operating system as a hechunyang user
4. Log in to MySQL 8.0.18
[root@localhost soft] # su-hechunyangLast login: Fri Nov 8 16:40:53 CST 2019 on pts/0 [hechunyang@localhost ~] $[hechunyang@localhost] $[hechunyang@localhost ~] $/ usr/local/mysql/bin/mysql-S / tmp/mysql_hcy.sock-uhechunyang-e "select version () "+-+ | version () | +-+ | 8.0.18 | +-+ [hechunyang@localhost ~] $
In this example, user hechunyang is logged into the operating system and has full shell access. He has authenticated using the operating system, and his MySQL account has been configured to use the unix_socket authentication plug-in, so he does not need to authenticate the database again. MySQL accepts his operating system credentials and allows him to connect.