Search code examples
mysqlcentoscentos7

Mysql service is not starting in centos 7


i have installed mysql-community-server in my centos 7.9 machine, its service is not starting and giving me error while starting the service due to that i am unable to run mysql_secure_installation script as well

here's the error that i am facing while starting the service

 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.

here's the log 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.

i have tried every solution but unable to figure out what's wrong with it. here's my /etc/my.conf file details.

# 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

Solution

  • I have resolved the issue following is the solution

    stop the service

    systemctl stop mysqld
    

    deleting all the files and directories from /var/lib/mysql

    rm -rf /var/lib/mysql/*
    

    start the service

    systemctl start mysqld