问题描述
我在 Ubuntu 16.04 上的 MariaDB 上有一个 root 用户.
I've a root User on the MariaDB on Ubuntu 16.04.
默认情况下,root 用户由 unix_socket
身份验证插件进行身份验证.
As default the root user is authenticated by the unix_socket
authentication plugin.
我可以通过设置将认证方式切换为密码方式
I can switch the authentication method to password method by setting
update mysql.user set plugin='' where user='root';
这很好用.但是……
是否有可能通过 unix_socket(通过 root shell)或密码(当它通过 localhost:3306 连接时)验证 root 用户?
Is there a possibility to authenticate the root user by unix_socket (by root shell) or by password (when it is connected by localhost:3306)?
推荐答案
一种可靠且直接的方法是创建另一个超级用户并在您想通过密码连接时使用它.
A reliable and straightforward way would be to create another super-user and use it when you want to connect by password.
CREATE USER admin@localhost IDENTIFIED BY 'password';
GRANT ALL ON *.* TO admin@localhost WITH GRANT OPTION;
-- etc
这篇关于为 MariaDB 根用户启用密码和 unix_socket 身份验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!