MariaDB - cannot login as root(MariaDB - 无法以 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' identify 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 生成的包默认具有 unix_socket 本地根身份验证.要检查,请运行
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 身份登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:MariaDB - 无法以 root 身份登录
基础教程推荐
- 无法在 ubuntu 中启动 mysql 服务器 2021-01-01
- 在 VB.NET 中更新 SQL Server DateTime 列 2021-01-01
- 如何在 SQL Server 的嵌套过程中处理事务? 2021-01-01
- ERROR 2006 (HY000): MySQL 服务器已经消失 2021-01-01
- Sql Server 字符串到日期的转换 2021-01-01
- 使用pyodbc“不安全"的Python多处理和数据库访问? 2022-01-01
- SQL Server 2016更改对象所有者 2022-01-01
- SQL Server 中单行 MERGE/upsert 的语法 2021-01-01
- SQL Server:只有 GROUP BY 中的最后一个条目 2021-01-01
- 将数据从 MS SQL 迁移到 PostgreSQL? 2022-01-01