今天启动mysql的时候报了错ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'
运行
systemctl status mysql.service
发现报错
image.png
查看具体错误日志/var/mysql/error.log
2020-09-23T08:40:40.110099Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2020-09-23T08:40:40.110101Z 0 [Note] InnoDB: Uses event mutexes
2020-09-23T08:40:40.110103Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2020-09-23T08:40:40.110105Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-09-23T08:40:40.110109Z 0 [Note] InnoDB: Using Linux native AIO
2020-09-23T08:40:40.110789Z 0 [Note] InnoDB: Number of pools: 1
2020-09-23T08:40:40.214397Z 0 [Note] InnoDB: Using CPU crc32 instructions
2020-09-23T08:40:40.273755Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2020-09-23T08:40:40.438964Z 0 [Note] InnoDB: Completed initialization of buffer pool
2020-09-23T08:40:40.624783Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2020-09-23T08:40:41.001504Z 0 [ERROR] InnoDB: Database page corruption on disk or a failed file read of page [page id: space=0, page number=5]. You may have to recover from a backup.
2020-09-23T08:40:41.001519Z 0 [Note] InnoDB: Page dump in ascii and hex (16384 bytes):
问题原因总结:
因为数据库中存在表损坏,进而导致数据访问错误,导致mysql启动失败;mysql中check table 发现表有损坏,但表是innodb类型无法修复
解决:
在MySQL的配置文件/etc/mysql/mysql.conf.d/mysqld.cnf中加入
innodb_force_recovery=1
强制recovery,重启mysql可以启动成功
sudo service mysql restart
网友评论