MariaDB-无法以root用户身份登录 [英] MariaDB - cannot login as root
问题描述
我正在尝试在Ubuntu(16.04.02)上设置MariaDB(10.0.29).安装并启动进程(sudo service mysql start
)后,即使我最初将密码设置为空白,也无法以root
身份登录.
I am trying to setup MariaDB (10.0.29) on Ubuntu (16.04.02). After I installed it and started the process (sudo service mysql start
), I cannot login as root
even though I originally set the password to blank.
即mysql -u root
将拒绝我访问.我通过sudo mysql
登录并检查了用户表,即. select user, password, authentication_string from mysql.user
并按预期:
Ie mysql -u root
will deny me access. I logged in through sudo mysql
and checked the user table, ie. select user, password, authentication_string from mysql.user
and as expected:
+---------+----------+-----------------------+
| User | password | authentication_string |
+---------+----------+-----------------------+
| root | | |
+---------+----------+-----------------------+
我还创建了一个新用户,即. create user 'test'@'localhost' identified by '';
,当我尝试执行mysql -u test
(空密码)时,它会按预期工作并登录我.
I also created a new user, ie. create user 'test'@'localhost' identified by '';
and when I try to do mysql -u test
(empty password), it works as expected and logs me in.
用户表如下:
+---------+----------+-----------------------+
| User | password | authentication_string |
+---------+----------+-----------------------+
| root | | |
| test | | |
+---------+----------+-----------------------+
那么,有谁能告诉我为什么我不能使用空密码以root
身份登录,但可以以test
身份登录?
So, can anyone tell me why I cannot login as root
with empty password but I can login as test
?
推荐答案
与本地MariaDB软件包(由MariaDB本身提供的软件包)不同,Ubuntu默认生成的软件包具有
Unlike native MariaDB packages (those provided by MariaDB itself), packages generated by Ubuntu by default have unix_socket authentication for the local root. To check, run
SELECT user, host, plugin FROM mysql.user;
如果您在plugin
列中看到unix_socket
,这就是原因.
If you see unix_socket
in the plugin
column, that's the reason.
要返回通常的密码身份验证,请运行
To return to the usual password authentication, run
UPDATE mysql.user SET plugin = '' WHERE plugin = 'unix_socket';
FLUSH PRIVILEGES;
(选择适合您目的的WHERE
子句,上面的只是一个示例)
(choose the WHERE
clause which fits your purposes, the one above is just an example)
这篇关于MariaDB-无法以root用户身份登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!