Get the App
SLTechnology News&Howtos  ›  Database  › 

MySQL 8.0.18 adds authentication plug-in-Unix So

Shulou Source: shulou.com Published: 2022-06-01 22:37:32 11月07日 Update

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.

Tags: Operating system login plug-in identity authentication data database user account credential version popular again function socket that is account file time Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB NVidia macOS Huawei Docker