MariaDB 警告:'root@localhost' 都有...密码将被忽略

MariaDB Warning: 'root@localhost' has both ... The password will be ignored

我已经在 Ubuntu LTS 16.04 上安装了 MariaDB。然后我有 运行

/usr/bin/mysql_secure_installation

并设置root密码。通过 mysql -u root -p 访问数据库工作正常。但是使用 service mysql status 检查状态会打开一个带有此警告的日志文件:

[Warning] 'user' entry 'root@localhost' has both a password and an authentication plugin specified. The password will be ignored.

问题是:

  1. 这是一种担心还是完全正常?
  2. 如果这是一个问题,我该如何解决?

这是正常的,如果说 "accessing the DB via mysql -u root -p works fine" 你的意思是你 运行 在系统根目录下(或在 sudo).普通用户应该做不到。

默认情况下,由 Ubuntu 生成的包具有本地根目录的 unix_socket 身份验证。要检查,运行

SELECT user, host, plugin FROM mysql.user;

您应该会在 root@localhostplugin 列中看到 unix_socket

如果您想改用密码验证,运行

UPDATE mysql.user SET plugin = '' WHERE plugin = 'unix_socket';
FLUSH PRIVILEGES;