通过shell终端中可以免密码登陆mysql -uroot
,但是使用navicat for mariadb登陆报错:1698 - Access denied for user 'root'@'localhost'
Server version: 10.1.38-MariaDB-0+deb9u1 Debian 9.8
MariaDB [mysql]> select user,host,plugin from user where user='root'\G;
*************************** 1. row ***************************
user: root
host: %
plugin: unix_socket
1 row in set (0.00 sec)
可以看到root仅仅允许本地unix socket登陆。
关于unix_socket的介绍:
The unix_socket authentication plugin allows the user to use operating system credentials when connecting to MariaDB via the local Unix socket file. This Unix socket file is defined by the socket system variable.
The unix_socket authentication plugin works by calling the getsockopt system call with the SO_PEERCRED socket option, which allows it to retrieve the uid of the proces