【问题标题】:MySqlTuner - Failed: return code 256MySqlTuner - 失败:返回码 256
【发布时间】:2016-04-08 14:03:35
【问题描述】:

我们正在尝试使用 mysqltuner 来了解我们的 Wordpress 网站上的一些问题背后可能存在的问题,但在运行它时几乎没有问题(主要是无法执行/返回代码:256)。

首先我们做了:

wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master/mysqltuner.pl

并执行它:

perl mysqltuner.pl

但这就是我们得到的:

 >>  MySQLTuner 1.6.9 - Major Hayden <major@mhtx.net>
 >>  Bug reports, feature requests, and downloads at http://mysqltuner.com/
 >>  Run with '--help' for additional options and output filtering

[--] Skipped version check for MySQLTuner script
[!!] failed to execute: SELECT VERSION()
[!!] FAIL Execute SQL / return code: 256
[!!] failed to execute: SHOW /*!50000 GLOBAL */ VARIABLES
[!!] FAIL Execute SQL / return code: 256
[!!] failed to execute: SHOW /*!50000 GLOBAL */ STATUS
[!!] FAIL Execute SQL / return code: 256
[!!] failed to execute: SHOW ENGINES
[!!] FAIL Execute SQL / return code: 256
[!!] failed to execute: SHOW SLAVE STATUS\G
[!!] FAIL Execute SQL / return code: 256
[!!] failed to execute: SHOW SLAVE HOSTS
[!!] FAIL Execute SQL / return code: 256
[!!] failed to execute: \s
[!!] FAIL Execute SQL / return code: 256
Use of uninitialized value $myvar{"version"} in pattern match (m//) at
    mysqltuner.pl line 1526 (#1)
    (W uninitialized) An undefined value was used as if it were already
    defined.  It was interpreted as a "" or a 0, but maybe it was a mistake.
    To suppress this warning assign a defined value to your variables.

    To help you figure out what was undefined, perl will try to tell you the
    name of the variable (if any) that was undefined. In some cases it cannot
    do this, so it also tells you what operation you used the undefined value
    in.  Note, however, that perl optimizes your program and the operation
    displayed in the warning may not necessarily appear literally in your
    program.  For example, "that $foo" is usually optimized into "that "
    . $foo, and the warning will refer to the concatenation (.) operator,
    even though there is no . in your program.

Use of uninitialized value $mysqlvermajor in numeric gt (>) at mysqltuner.pl
    line 1552 (#1)
Use of uninitialized value $mysqlvermajor in numeric eq (==) at mysqltuner.pl
    line 1552 (#1)
Use of uninitialized value $myvar{"version"} in concatenation (.) or string at
    mysqltuner.pl line 1531 (#1)
[!!] Your MySQL version  is EOL software!  Upgrade soon!
[OK] Operating on 64-bit architecture

-------- Storage Engine Statistics -------------------------------------------
[!!] failed to execute: SHOW DATABASES
[!!] FAIL Execute SQL / return code: 256
[--] Status: -Archive -BDB -Federated -InnoDB -ISAM -NDBCluster 
[OK] Total fragmented tables: 0
[!!] failed to execute: SELECT ~0
[!!] FAIL Execute SQL / return code: 256

-------- Security Recommendations  -------------------------------------------
Use of uninitialized value $myvar{"version"} in pattern match (m//) at
    mysqltuner.pl line 1345 (#1)
[!!] failed to execute: SELECT CONCAT(user, '@', host) FROM mysql.user WHERE TRIM(USER) = '' OR USER IS NULL
[!!] FAIL Execute SQL / return code: 256
[OK] There are no anonymous accounts for any database users
[!!] failed to execute: SELECT CONCAT(user, '@', host) FROM mysql.user WHERE (password = '' OR password IS NULL) AND plugin NOT IN ('unix_socket', 'win_socket')
[!!] FAIL Execute SQL / return code: 256
[OK] All database users have passwords assigned
[!!] failed to execute: SELECT CONCAT(user, '@', host) FROM mysql.user WHERE CAST(password as Binary) = PASSWORD(user) OR CAST(password as Binary) = PASSWORD(UPPER(user)) OR CAST(password as Binary) = PASSWORD(UPPER(LEFT(User, 1)) + SUBSTRING(User, 2, LENGTH(User)))
[!!] FAIL Execute SQL / return code: 256
[!!] failed to execute: SELECT CONCAT(user, '@', host) FROM mysql.user WHERE HOST='%'
[!!] FAIL Execute SQL / return code: 256
[!!] There is no basic password file list!

-------- CVE Security Recommendations  ---------------------------------------
[--] Skipped due to --cvefile option undefined
Use of uninitialized value $mystat{"Questions"} in numeric lt (<) at
    mysqltuner.pl line 1868 (#1)
[!!] Your server has not answered any queries - cannot continue...

我们不明白可能是什么问题。提前谢谢大家!

【问题讨论】:

  • 看起来您指定的凭据无效。您是否设置了任何凭据?另外,为什么你认为 mysql Tuner 脚本可以检测与 wordpress 相关的问题?
  • 亲爱的@Mjh 感谢您的快速回复。我们以 root 身份运行 mysqltuner,我们没有被要求提供任何凭据。我们不认为 mysqltuner 可以检测到 Wordpress 问题,但我们正在研究许多变量,包括:php-fpm 慢日志、mysql 慢日志,如果有任何错误配置,我们还想检查 mysqltuner。
  • 我尝试使用:perl mysqltuner.pl --host localhost --user root 运行它,第一行输出是 [--] Performing tests on localhost:3306 [OK] Logged in using credentials passed on the command line,所以它看起来不错,但它不断提供所有失败的统计信息
  • 如果你让它运行,忽略它所说的“碎片表”;这是假的。
  • 您可以通过在此论坛中搜索“Wordpress”获得更多信息;有很多关于性能等的讨论;你可以听听其他人的发现。

标签: mysql mariadb mysqltuner


【解决方案1】:

由于更改listen 端口/重命名root 用户并禁用无密码local 登录,我遇到了同样的错误,但使用以下方法修复了它:

/path/to/mysqltuner.pl --port xxxx --user xxxx --pass xxxx

(假设localhost 没有--host 开关和端口3306 假设没有--port 开关)

运行mysqltuner 的更好方法是使用limited_user 的一些凭据设置/root/.my.cnf(任何名称都可以):

[client]
user=limited_user
pass=thatuserspassword

然后我就可以使用 limited_user

/path/to/mysqltuner.pl --port 5555 --user limited_user

limited_user 只需要以下权限:

SHOW DATABASES, LOCK TABLES, SELECT ON *.*

& 可选SHOW SLAVE STATUS & SHOW SLAVE HOSTS

【讨论】:

    猜你喜欢
    • 2015-02-18
    • 2016-06-05
    • 1970-01-01
    • 1970-01-01
    • 2018-06-07
    • 2014-02-01
    • 1970-01-01
    • 2012-08-12
    • 2011-10-14
    相关资源
    最近更新 更多