刚刚搭建数据库时,在对数据库进行初始化时遇到这样的错误:
Error 2002 (HY000) : can’t connect to local mysql server through socket’/var/lib/mysql/mysql.sock’ (111)
而日志文件的报错是这样的:
2021-05-12 14:55:48 0 [Note] InnoDB: Checksum mismatch in datafile: ./ibdata1, Space ID:0, Flags: 0
2021-05-12 14:55:48 0 [ERROR] InnoDB: Corrupted page [page id: space=0, page number=0] of datafile './ibdata1' could not be found in the doublewrite buffer.
2021-05-12 14:55:48 0 [ERROR] InnoDB: Plugin initialization aborted with error Data structure corruption
2021-05-12 14:55:49 0 [Note] InnoDB: Starting shutdown...
2021-05-12 14:55:49 0 [ERROR] Plugin 'InnoDB' init function returned error.
2021-05-12 14:55:49 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2021-05-12 14:55:49 0 [Note] Plugin 'FEEDBACK' is disabled.
2021-05-12 14:55:49 0 [ERROR] Unknown/unsupported storage engine: innodb
2021-05-12 14:55:49 0 [ERROR] Aborting
在网上搜了很多情况,它们大多的报错都是:
Error 2002 (HY000) : can’t connect to local mysql server through socket’/var/lib/mysql/mysql.sock’ (2)
而我的报错结尾是(111)
后来自己输入journalctl -xe查看得出的结果:
5月 12 16:05:49 controller mysql-check-socket[19092]: Socket file /var/lib/mysql/mysql.sock exists.
5月 12 16:05:49 controller mysql-check-socket[19092]: No process is using /var/lib/mysql/mysql.sock, which means it is a garbage, so it
5月 12 16:05:49 controller mysql-prepare-db-dir[19123]: Database MariaDB is probably initialized in /var/lib/mysql already, nothing is d
5月 12 16:05:49 controller mysql-prepare-db-dir[19123]: If this is not the case, make sure the /var/lib/mysql is empty before running my
5月 12 16:05:49 controller mysqld[19163]: 2021-05-12 16:05:49 0 [Note] /usr/libexec/mysqld (mysqld 10.3.20-MariaDB) starting as process
5月 12 16:05:49 controller mysqld[19163]: 2021-05-12 16:05:49 0 [Warning] Could not increase number of max_open_files to more than 1024
5月 12 16:05:49 controller mysqld[19163]: 2021-05-12 16:05:49 0 [Warning] Changed limits: max_open_files: 1024 max_connections: 594 (wa
5月 12 16:05:50 controller systemd[1]: mariadb.service: main process exited, code=exited, status=1/FAILURE
5月 12 16:05:50 controller systemd[1]: Failed to start MariaDB 10.3 database server.
注意这一句话:
5月 12 16:05:49 controller mysql-prepare-db-dir[19123]: If this is not the case, make sure the /var/lib/mysql is empty before running my
意思是如果不是上述情况请将/var/lib/mysql/目录下的文件清空
rm -rf /var/lib/mysql/*
systemctl restart mariadb
服务启动成功
● mariadb.service - MariaDB 10.3 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Active: active (running) since 三 2021-05-12 16:07:37 CST; 11min ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Process: 19473 ExecStartPost=/usr/libexec/mysql-check-upgrade (code=exited, status=0/SUCCESS)
Process: 19334 ExecStartPre=/usr/libexec/mysql-prepare-db-dir %n (code=exited, status=0/SUCCESS)
Process: 19307 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
Main PID: 19442 (mysqld)
Status: "Taking your SQL requests now..."
Tasks: 30
CGroup: /system.slice/mariadb.service
└─19442 /usr/libexec/mysqld --basedir=/usr
版权声明:本文为system_rookie原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。