MySQL 服务器未启动。服务器端SQL语句不好?损坏的表?面板自动更新?
Posted
技术标签:
【中文标题】MySQL 服务器未启动。服务器端SQL语句不好?损坏的表?面板自动更新?【英文标题】:MySQL server not starting. Server-side SQL bad statement? Corrupted table? Cpanel autoupdate? 【发布时间】:2021-08-02 03:24:59 【问题描述】:昨天,我的专用服务器上的 mysql 服务停止工作,关闭了几个网页和在其上运行的其他应用程序。也许 cpanel 自动更新没有正确完成,但我只收到了带有此错误的警告电子邮件:
(XID ######) The “mysql” service is down.
第一个说:
The subprocess “/usr/local/cpanel/scripts/restartsrv_mysql” reported error number 2 when it ended.
系统和服务器信息:
操作系统:CentOS Linux 8.3 Apache 版本:2.4.46 MySQL 版本:版本 8.0.25,适用于 x86_64 上的 Linux(MySQL 社区服务器 - GPL) php 版本:7.4.18 Cpanel v94.0.8我将列出我尝试过的一些命令及其输出:
# systemctl start mysqld
Job for mysqld.service failed because the control process exited with error code.
See "systemctl status mysqld.service" and "journalctl -xe" for details.
然后:
# systemctl status mysqld.service
ESCOD
mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/mysqld.service.d
└─limits.conf
Active: failed (Result: exit-code) since Tue 2021-05-11 17:33:19 UTC; 53s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 27686 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS (code=exited, status=1/FAILURE)
Process: 27657 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 27686 (code=exited, status=1/FAILURE)
Status: "Server upgrade complete"
Error: 2 (No such file or directory)
May 11 17:33:17 xx-xx-xx-xx.cprapid.com mysqld[27686]: 2021-05-11T17:33:17.655235Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock>
May 11 17:33:17 xx-xx-xx-xx.cprapid.com mysqld[27686]: 2021-05-11T17:33:17.670697Z 4 [System] [MY-013381] [Server] Server upgrade frrom '80024' to '80025' started.>
May 11 17:33:18 xx-xx-xx-xx.cprapid.com mysqld[27686]: 2021-05-11T17:33:18.064279Z 4 [ERROR] [MY-010725] [Server] Couldn't repair table: mysql.general_log>
May 11 17:33:18 xx-xx-xx-xx.cprapid.com mysqld[27686]: 2021-05-11T17:33:18.064383Z 4 [ERROR] [MY-013178] [Server] Execution of server-side SQL statement '-- Create general_log CREATE TABLE IF NOT EXISTS general_log (event_time TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), user_host MEDIUMTEXT NOT NULL, thread_id BIGINT UNSIGNED NOT NULL, server_id INTEGER UNSIGNED NOT NULL, command_type VARCHAR(64) NOT NULL, argument MEDIUMBLOB NOT NULL) engine=CSV CHARACTER SET utf8 comment="General log"; 'failed with error code = 1034, error message = 'Incorrect key file for table 'general_log'; try to repair it'.>>
May 11 17:33:18 xx-xx-xx-xx.cprapid.com mysqld[27686]: 2021-05-11T17:33:18.065026Z 0 [ERROR] [MY-013380] [Server] Failed to upgrade >
May 11 17:33:18 xx-xx-xx-xx.cprapid.com mysqld[27686]: 2021-05-11T17:33:18.065176Z 0 [ERROR] [MY-010119] [Server] Aborting
May 11 17:33:18 xx-xx-xx-xx.cprapid.com mysqld[27686]: 2021-05-11T17:33:18.987996Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.25) MySQL Community Server - GPL.>
May 11 17:33:19 xx-xx-xx-xx.cprapid.com systemd[1]: mysqld.service: Main process exited, code=exited, status=1/FAILURE
May 11 17:33:19 xx-xx-xx-xx.cprapid.com systemd[1]: mysqld.service: Failed with result 'exit-code'.
May 11 17:33:19 xx-xx-xx-xx.cprapid.com systemd[1]: Failed to start MySQL Server.
# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
此文件不存在,但有一个位于 /tmp/mysql.sock
。后来我在my.cnf中改了几行还是一样的错误
#mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
# nano /etc/my.cnf
[client]
socket=/tmp/mysql.sock
[mysqld]
disable-log-bin=1
default-authentication-plugin=mysql_native_password
innodb_file_per_table=1
performance-schema=0
socket=/tmp/mysql.sock
如前所述,我将客户端和 mysqld 的 socket=/var/lib/mysql/mysql.sock
更改为 socket=/tmp/mysql.sock
。不再进行任何更改。
# mysqld -u root
2021-05-11T17:11:04.993623Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.25) starting as process 25020
2021-05-11T17:11:04.997863Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-05-11T17:11:05.146263Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2021-05-11T17:11:05.432633Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: /var/run/mysqld/mysqlx.sock
2021-05-11T17:11:05.447752Z 4 [System] [MY-013381] [Server] Server upgrade from '80024' to '80025' started.
2021-05-11T17:11:10.666062Z 4 [ERROR] [MY-013178] [Server] Execution of server-side SQL statement 'ALTER TABLE user MODIFY max_updates int unsigned DEFAULT 0 NOT NULL, MODIFY max_connections int unsigned DEFAULT 0 NOT NULL, MODIFY max_user_connections int unsigned DEFAULT 0 NOT NULL, MODIFY ssl_cipher BLOB NOT NULL, MODIFY x509_issuer BLOB NOT NULL, MODIFY x509_subject BLOB NOT NULL; ' failed with error code = 1138, error message = 'Invalid use of NULL value'.
2021-05-11T17:11:10.666934Z 0 [ERROR] [MY-013380] [Server] Failed to upgrade server.
2021-05-11T17:11:10.667061Z 0 [ERROR] [MY-010119] [Server] Aborting
2021-05-11T17:11:12.059278Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.25) MySQL Community Server - GPL.
在这里我发现了有趣的'ALTER TABLE user MODIFY...
似乎有一个额外的空间(对不起,如果这不重要,我不是这方面的专家)。
# ls -la /var/lib |grep mysql
drwxr-x--x 10 mysql mysql 4096 May 12 00:24 mysql
drwxr-x--- 2 mysql mysql 6 Apr 23 16:18 mysql-files
drwxr-x--- 2 mysql mysql 6 Apr 23 16:18 mysql-keyring
最后,在检测到该事件后,服务器在一个小时左右没有响应 ping,需要拔下电源并重新启动。现在我可以通过 ssh 访问服务器,但 mysql 仍然无法正常工作。
【问题讨论】:
【参考方案1】:如果您打开了“常规日志”,请将其关闭。
我在更新日志中没有发现任何明显的内容:https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-25.html
考虑在 bugs.mysql.com 提交错误
mysql
目录中有哪些“一般*”文件? 可能只删除这些文件。
更多
失败,错误代码 = 13,错误消息
perror 13
OS error code 13: Permission denied
谁在写?谁在运行 mysqld?等等
MySQL 应由root
安装,mysqld
应由系统进程而非用户进程运行。
【讨论】:
好的,“常规日志”已关闭。 "general*" 文件是什么意思? mysql目录下有pem's、auto.cnf、mysql.ibd等和db's、mysql、performance_schema、sys等目录。 @AsessionGuy - 可能是general.csv
;也许general.frm
.
general_log.csv
和 general_log.csm
在 /var/lib/mysql/mysql/
中
删除这两个文件可能有助于启动。 (mv
他们到其他地方,以防这个修复让事情变得更糟。)
嗯,没用但是错误改成Execution of server-side SQL statement '-- Create general_log CREATE TABLE IF NOT EXISTS general_log (event_time TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), user_host MEDIUMTEXT NOT NULL, thread_id BIGINT UNSIGNED NOT NULL, server_id INTEGER UNSIGNED NOT NULL, command_type VARCHAR(64) NOT NULL, argument MEDIUMBLOB NOT NULL) engine=CSV CHARACTER SET utf8 comment="General log"; ' failed with error code = 13, error message = 'Can't get stat of './mysql/general_log.CSV' (OS errno 2 - No such file or directory)'.
以上是关于MySQL 服务器未启动。服务器端SQL语句不好?损坏的表?面板自动更新?的主要内容,如果未能解决你的问题,请参考以下文章