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

2022-01-15 00:00:00 root warnings passwords mariadb mysql

我已经在 Ubuntu LTS 16.04 上安装了 MariaDB.然后我跑了

I have installed MariaDB on Ubuntu LTS 16.04. Then I have run

/usr/bin/mysql_secure_installation

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

and set a root password. Accessing the DB via mysql -u root -p works fine. But checking the status with service mysql status opens a log file with this warning:

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

问题是:

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

推荐答案

正常,如果说通过mysql -u root -p访问数据库正常"em> 你的意思是你在作为系统根目录(或在 sudo 下)运行它.普通用户应该是做不到的.

It is normal, if by saying "accessing the DB via mysql -u root -p works fine" you mean that you are running it while being a system root (or under sudo). You should not be able to do it as an ordinary user.

Ubuntu 生成的包默认具有本地的 unix_socket 身份验证根.要检查,请运行

Packages generated by Ubuntu by default have unix_socket authentication for the local root. To check, run

SELECT user, host, plugin FROM mysql.user;

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

You should see unix_socket in the plugin column for root@localhost.

如果你想使用密码验证,运行

If you want to use the password authentication instead, run

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

相关文章