【问题标题】:MariaDB Warning: 'root@localhost' has both ... The password will be ignoredMariaDB 警告:'root@localhost' 两者都有...密码将被忽略
【发布时间】:2017-09-12 08:11:14
【问题描述】:

我已经在 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. 如果这是一个问题,我该如何解决?

【问题讨论】:

    标签: mysql passwords warnings mariadb root


    【解决方案1】:

    这是正常的,如果说“通过mysql -u root -p 访问数据库工作正常”您的意思是您在作为系统根(或在sudo 下)运行它。普通用户应该是做不到的。

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

    SELECT user, host, plugin FROM mysql.user;
    

    您应该在plugin 列中看到unix_socket root@localhost

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

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

    【讨论】:

    • 非常感谢您的详细回复(很抱歉无法为您的答案投票)!这摆脱了警告。但是,在服务器重新启动后 MariaDB 重新启动后,我现在在状态日志中看到 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)。另外,通过service mysql restart重新启动 MariaDB 不再起作用了?!?
    • Ubuntu 必须相应地更改了其他脚本。启动和监视服务的旧方法是拥有一个特殊的debian-sys-maint 用户,它有自己的debian.conf,其中包含一个生成的密码。据我了解,开始使用unix_socket 的原因之一是摆脱这个相当尴尬的遗留问题。如果您想继续使用这些脚本,我通常的建议是按照 Ubuntu 的要求保留 root@localhost(使用 unix_socket),并另外创建另一个超级用户,您将使用密码身份验证并用于您的目的。
    猜你喜欢
    • 2015-03-10
    • 2021-06-10
    • 2015-11-05
    • 2018-01-12
    • 2016-07-10
    • 1970-01-01
    • 2019-06-05
    • 1970-01-01
    • 2017-06-01
    相关资源
    最近更新 更多