无法在 Centos 7 操作系统的 Linux 服务器上启动 MySQL

无法在 Centos 7 操作系统的 Linux 服务器上启动 MySQL

我已经通过以下命令在服务器(Centos 7)中安装了 MySQL:

yum install -y mysql
yum install -y mysql-server
yum install -y mysql-devel

安装后,我输入mysql并遇到错误

ERROR 2002 (HY000): Can't connect to local MySQL server through socket 
'/var/mysql/mysql.sock' (2)

我认为是因为我还没有启动MySQL服务,所以我输入命令

service mysqld start

然后我收到消息说Job for mariadb.service failed

这是内容/etc/my.cnf

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid

但是,该文件/var/lib/mysql/mysql.sock在我的服务器中不存在。顺便说一句,SELINUX 是手动禁用的。

mariadb.log节目

InnoDB: Error: log file ./ib_logfile0 is of different size 0 50331648 bytes
InnoDB: than specified in the .cnf file 0 5242880 bytes!
InnoDB: Possible causes for this error:
   (a) Incorrect log file is used or log file size is changed
   (b) In case default size is used this log file is from 10.0
   (c) Log file is corrupted or there was not enough disk space
   In case (b) you need to set innodb_log_file_size = 48M
[ERROR] Plugin 'InnoDB' init function returned error.
[ERROR] Plugin 'InnoDB' registration as a STORAGE ENGIN failed.
[ERROR] Unknown/unsupported storage engine: innodb
[ERROR] Aborting

答案1

我解决了这个问题,所以我想自己回答一下。如果这种自答行为不妥,请在下方提出评论。

总的来说,我通过找出文件中列出的问题来解决这个问题/var/log/mariadb/maridb.log

首先,我删除了文件./ib_logfile0中指出超出大小限制的log。然后,我尝试使用enable+ startmariadb systemctl,再次失败。maridb.logIncorrect information in file './mysql/proxies_priv.frm'。通过备份不正确的文件并重新启动mysql,maridb终于OK了。

相关内容