16.04 MariaDB->系统日志中的错误(mysqlcheck)

16.04 MariaDB->系统日志中的错误(mysqlcheck)

在我按照这个非常棒的教程从 Scratch 安装 Ubuntu 16.04 和 MariaDB 后,我发现系统日志中出现了以下故障 https://www.howtoforge.com/tutorial/install-apache-with-php-and-mysql-on-ubuntu-16-04-lamp/

    May 14 12:00:13 fortuna /etc/mysql/debian-start[1466]: /usr/bin/mysql_upgrade: the '--basedir' option is always ignored
May 14 12:00:13 fortuna /etc/mysql/debian-start[1466]: Looking for 'mysql' as: /usr/bin/mysql
May 14 12:00:13 fortuna /etc/mysql/debian-start[1466]: Looking for 'mysqlcheck' as: /usr/bin/mysqlcheck
May 14 12:00:13 fortuna /etc/mysql/debian-start[1466]: Version check failed. Got the following error when calling the 'mysql' command line client
May 14 12:00:13 fortuna /etc/mysql/debian-start[1466]: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
May 14 12:00:13 fortuna /etc/mysql/debian-start[1466]: FATAL ERROR: Upgrade failed
May 14 12:00:13 fortuna /etc/mysql/debian-start[1487]: Checking for insecure root accounts.
May 14 12:00:13 fortuna mysql[1020]: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

我已经在 /root 目录中创建了一个 .my.cnf。如果我以 root 身份运行“mysql”,我就可以不用密码登录。(见下文)

root@fortuna:~# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 7071
Server version: 10.0.24-MariaDB-7 Ubuntu 16.04


Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.


Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


MariaDB [(none)]>

但是如果我尝试使用 mysqlcheck 检查,我会收到如下错误:

root@fortuna:~# /usr/bin/mysqlcheck --defaults-file=/etc/mysql/debian.cnf --all-databases --fast --silent
/usr/bin/mysqlcheck: Got error: 1045: Access denied for user 'root'@'localhost' (using password: NO) when trying to connect

如果我仔细查看,就会发现有一个文件 /etc/mysql/debian.cnf,其中应该包含密码。但其中没有列出密码。另一方面,我不应该在这里输入密码,因为它说“请勿触摸”!我该怎么办?

# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host     = localhost
user     = root
password = 
socket   = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host     = localhost
user     = root
password = 
socket   = /var/run/mysqld/mysqld.sock
basedir  = /usr

答案1

对我来说,目前最兼容的解决方案是在

 /etc/mysql/debian.cnf 

此外,我还提交了一个错误报告。 https://bugs.launchpad.net/ubuntu/+source/mariadb-10.0/+bug/1582209

答案2

尝试将该文本添加到您的 my.cnf 并替换--defaults-file=/etc/mysql/debian.cnf–默认文件=〜/.my.cnf包括你的密码。你的请求被拒绝,因为 debian.cnf 覆盖了 [client]。如果 .my.cnf 看起来像:

[client]
user=mysqluser
password=mysqlpass

相关内容