Mysql 服务在 centos 7 中未启动

问题描述 投票:0回答:2

我已经在我的centos 7.9机器上安装了mysql-community-server,它的服务没有启动,并在启动服务时给我错误,因为我也无法运行mysql_secure_installation脚本

这是我在启动服务时遇到的错误

 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.

这是日志详细信息

 tail -n 20 /var/log/mysqld.log
2021-11-30T09:38:45.003421Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-11-30T09:38:45.045895Z 1 [ERROR] [MY-012592] [InnoDB] Operating system error number 2 in a file operation.
2021-11-30T09:38:45.045946Z 1 [ERROR] [MY-012593] [InnoDB] The error means the system cannot find the path specified.
2021-11-30T09:38:45.045966Z 1 [ERROR] [MY-012594] [InnoDB] If you are installing InnoDB, remember that you must create directories yourself, InnoDB does not create them.
2021-11-30T09:38:45.045981Z 1 [ERROR] [MY-012646] [InnoDB] File ./ibdata1: 'open' returned OS error 71. Cannot continue operation
2021-11-30T09:38:45.045997Z 1 [ERROR] [MY-012981] [InnoDB] Cannot continue operation.
2021-11-30T09:38:50.955262Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.27) starting as process 55847
2021-11-30T09:38:51.008326Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-11-30T09:38:51.036852Z 1 [ERROR] [MY-012592] [InnoDB] Operating system error number 2 in a file operation.
2021-11-30T09:38:51.036942Z 1 [ERROR] [MY-012593] [InnoDB] The error means the system cannot find the path specified.
2021-11-30T09:38:51.036968Z 1 [ERROR] [MY-012594] [InnoDB] If you are installing InnoDB, remember that you must create directories yourself, InnoDB does not create them.
2021-11-30T09:38:51.036983Z 1 [ERROR] [MY-012646] [InnoDB] File ./ibdata1: 'open' returned OS error 71. Cannot continue operation
2021-11-30T09:38:51.037057Z 1 [ERROR] [MY-012981] [InnoDB] Cannot continue operation.
2021-11-30T09:38:57.011572Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.27) starting as process 55900
2021-11-30T09:38:57.034554Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-11-30T09:38:57.062981Z 1 [ERROR] [MY-012592] [InnoDB] Operating system error number 2 in a file operation.
2021-11-30T09:38:57.063054Z 1 [ERROR] [MY-012593] [InnoDB] The error means the system cannot find the path specified.
2021-11-30T09:38:57.063079Z 1 [ERROR] [MY-012594] [InnoDB] If you are installing InnoDB, remember that you must create directories yourself, InnoDB does not create them.
2021-11-30T09:38:57.063101Z 1 [ERROR] [MY-012646] [InnoDB] File ./ibdata1: 'open' returned OS error 71. Cannot continue operation
2021-11-30T09:38:57.063118Z 1 [ERROR] [MY-012981] [InnoDB] Cannot continue operation.

我已经尝试了所有解决方案,但无法找出问题所在。 这是我的 /etc/my.conf 文件详细信息。

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove the leading "# " to disable binary logging
# Binary logging captures changes between backups and is enabled by
# default. It's default setting is log_bin=binlog
# disable_log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#
# Remove leading # to revert to previous value for default_authentication_plugin,
# this will increase compatibility with older clients. For background, see:
# https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin
# default-authentication-plugin=mysql_native_password

datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
mysql centos centos7
2个回答
5
投票

我已经解决了问题,以下是解决方案

停止服务

systemctl stop mysqld

删除 /var/lib/mysql 中的所有文件和目录

rm -rf /var/lib/mysql/*

启动服务

systemctl start mysqld

0
投票

您正在运行 CentOS 7。运行以下命令:

systemctl status mysqld.service

如果没有出现错误,请尝试以下操作:

systemctl restart mysqld.service

如果失败,请运行以下命令:

for i in `ps auxf|grep mysqld|grep "grep" -v|awk '{print $2}'`; do kill -9 $i; done

然后,运行这个:

systemctl start mysqld.service

最后,确保其正常工作:

systemctl status mysqld.service
© www.soinside.com 2019 - 2024. All rights reserved.