mysqld 立即退出,日志中没有任何内容,strace 中的文件读取失败

mysqld 立即退出,日志中没有任何内容,strace 中的文件读取失败

我想要运行mysqld --skip-grant-tables(重置 root 密码)。

$ sudo mysqld --skip-grant-tables --explicit_defaults_for_timestamp=ON
2016-11-17 11:27:16 0 [Note] mysqld (mysqld 5.6.31-0ubuntu0.15.10.1) starting as process 5432 ...

然后它立即退出。/var/log/mysql 中没有任何内容生成。mysqld 尚未运行,直到一分钟前我将其终止,它一直运行良好。

编辑我从 strace 中取出了这些可疑的行

open("/var/log/mysql/error.log", O_WRONLY|O_CREAT|O_APPEND, 0666) = -1 EACCES (Permission denied)
^---- (error.log doesn't exist and I'm root so wtf?)
...
readlink("./mysql/plugin.MYI", 0x7ffe24c368c0, 511) = -1 EINVAL (Invalid argument)
readlink("./mysql/plugin.MYD", 0x7ffe24c36ac0, 511) = -1 EINVAL (Invalid argument)
access("./mysql/plugin.TRG", F_OK)      = -1 ENOENT (No such file or directory)
open("./ibdata1", O_RDWR|O_CREAT|O_EXCL, 0660) = -1 EEXIST (File exists)
stat("./ib_logfile2", 0x7ffe24c32e70)   = -1 ENOENT (No such file or directory)
stat("./undo001", 0x7ffe24c31e30)       = -1 ENOENT (No such file or directory)
open("./undo001", O_RDWR)               = -1 ENOENT (No such file or directory)
open("./mysql/innodb_index_stats.isl", O_RDWR) = -1 ENOENT (No such file or directory)
...
open("./phpmyadmin/pma__users.isl", O_RDWR) = -1 ENOENT (No such file or directory)
...
stat("/root/.mylogin.cnf", 0x7ffe24c36e50) = -1 EACCES (Permission denied)
unlink("/var/run/mysqld/mysqld.sock")   = -1 ENOENT (No such file or directory)
bind(12, {sa_family=AF_LOCAL, sun_path="/var/run/mysqld/mysqld.sock"}, 110) = -1 ENOENT (No such file or directory)

发生了什么?

答案1

该命令中止,因为你以 root 身份运行它, 尝试这个:

su - mysql -c 'mysqld --skip-grant-tables --explicit_defaults_for_timestamp=ON'

请注意,/var/log/mysql.log 中没有生成任何内容,因为 mysql 用户无法写入 /var/log。查看 /var/lib/mysql/YOURHOST.err 以进行记录。

答案2

strace 中的第一行意味着 /var/log/mysql 不属于 mysql,即运行 mysqld 的用户。

相关内容