Not able to start MySQL Service (Fedora Linux) - mysql

I am learning Web Development and am trying to set up a MySql Database for a Spring Boot Application. I am not able to make the MySql Database.
I downloaded mysql using:
sudo dnf install mysql-community-server
Then I got the following errors:
$ mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)
$ mysql --version
mysql Ver 8.0.31 for Linux on x86_64 (MySQL Community Server - GPL)
$ sudo service mysql start
Redirecting to /bin/systemctl start mysql.service
Failed to start mysql.service: Unit mysql.service not found.
$ sudo systemctl start mysqld
Job for mysqld.service failed because the control process exited with error code.
See "systemctl status mysqld.service" and "journalctl -xeu mysqld.service" for details.
$ systemctl status mysqld.service
× mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; preset: disabled)
Active: failed (Result: exit-code) since Wed 2022-11-30 06:22:00 IST; 4s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 3783 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Process: 3818 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS (code=exited, status=1/FAILURE)
Main PID: 3818 (code=exited, status=1/FAILURE)
Status: "Server shutdown complete"
Error: 22 (Invalid argument)
CPU: 1.043s
Nov 30 06:21:59 fedora systemd[1]: Starting mysqld.service - MySQL Server...
Nov 30 06:22:00 fedora systemd[1]: mysqld.service: Main process exited, code=exited, status=1/FAILURE
Nov 30 06:22:00 fedora systemd[1]: mysqld.service: Failed with result 'exit-code'.
Nov 30 06:22:00 fedora systemd[1]: Failed to start mysqld.service - MySQL Server.
Nov 30 06:22:00 fedora systemd[1]: mysqld.service: Consumed 1.043s CPU time.
I don't have much experience with mysql so I could not do much to fix the error. This [https://stackoverflow.com/questions/11657829/error-2002-hy000-cant-connect-to-local-mysql-server-through-socket-var-run] did not solve the issue. Reinstalling mysql (several times) and restarting my laptop also didn't help.
$ cat /etc/my.cnf
# 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=/run/mysqld/mysqld.pid
$ cat /etc/mysql/my.cnf
cat: /etc/mysql/my.cnf: No such file or directory
$ cat /var/lib/mysql/my.cnf
cat: /var/lib/mysql/my.cnf: No such file or directory
EDIT:
$ journalctl -xeu mysqld.service
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ An ExecStart= process belonging to unit mysqld.service has exited.
░░
░░ The process' exit code is 'exited' and its exit status is 1.
Nov 30 06:22:00 fedora systemd[1]: mysqld.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ The unit mysqld.service has entered the 'failed' state with result 'exit-code'.
Nov 30 06:22:00 fedora systemd[1]: Failed to start mysqld.service - MySQL Server.
░░ Subject: A start job for unit mysqld.service has failed
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ A start job for unit mysqld.service has finished with a failure.
░░
░░ The job identifier is 3531 and the job result is failed.
Nov 30 06:22:00 fedora systemd[1]: mysqld.service: Consumed 1.043s CPU time.
░░ Subject: Resources consumed by unit runtime
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ The unit mysqld.service completed and consumed the indicated resources.
Edit: Logs # /var/log/mysql*.log
2022-11-30T00:44:42.089067Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.31) initializing of server in progress as process 1064
2022-11-30T00:44:42.091892Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
2022-11-30T00:44:42.091960Z 0 [ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it.
2022-11-30T00:44:42.092006Z 0 [ERROR] [MY-010119] [Server] Aborting
2022-11-30T00:44:42.092083Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.31) MySQL Community Server - GPL.
2022-11-30T00:44:42.331797Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.31) starting as process 1069
2022-11-30T00:44:42.339299Z 0 [Warning] [MY-010075] [Server] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 2d9a3bde-7048-11ed-a7cd-f406413544b8.
2022-11-30T00:44:42.342844Z 1 [ERROR] [MY-011011] [Server] Failed to find valid data directory.
2022-11-30T00:44:42.342942Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2022-11-30T00:44:42.342960Z 0 [ERROR] [MY-010119] [Server] Aborting
2022-11-30T00:44:42.343234Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.31) MySQL Community Server - GPL.
2022-11-30T00:49:37.543811Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.31) initializing of server in progress as process 3714
2022-11-30T00:49:37.544916Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
2022-11-30T00:49:37.544934Z 0 [ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it.
2022-11-30T00:49:37.545003Z 0 [ERROR] [MY-010119] [Server] Aborting
2022-11-30T00:49:37.545083Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.31) MySQL Community Server - GPL.
2022-11-30T00:49:37.768975Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.31) starting as process 3719
2022-11-30T00:49:37.773567Z 1 [ERROR] [MY-011011] [Server] Failed to find valid data directory.
2022-11-30T00:49:37.773672Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2022-11-30T00:49:37.773705Z 0 [ERROR] [MY-010119] [Server] Aborting
2022-11-30T00:49:37.774047Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.31) MySQL Community Server - GPL.
2022-11-30T00:52:00.113630Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.31) initializing of server in progress as process 3813
2022-11-30T00:52:00.114677Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
2022-11-30T00:52:00.114695Z 0 [ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it.
2022-11-30T00:52:00.114738Z 0 [ERROR] [MY-010119] [Server] Aborting
2022-11-30T00:52:00.114840Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.31) MySQL Community Server - GPL.
2022-11-30T00:52:00.358242Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.31) starting as process 3818
2022-11-30T00:52:00.362438Z 1 [ERROR] [MY-011011] [Server] Failed to find valid data directory.
2022-11-30T00:52:00.362537Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2022-11-30T00:52:00.362566Z 0 [ERROR] [MY-010119] [Server] Aborting
2022-11-30T00:52:00.362844Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.31) MySQL Community Server - GPL.
Can someone tell me how to fix this?

So the following should cleanup /var/lib/mysql, and then mysql should be able to reinitialize cleanly upon start. This however WILL delete any existing databases, including users and their permissions:
sudo systemctl stop mysqld
sudo rm -rf /var/lib/mysql/
sudo mkdir -p /var/lib/mysql/
sudo chown -R mysql: /var/lib/mysql/
sudo systemctl start mysqld

Related

MySQL Restart Failed in MySQL 8.0.30

While Restarting the MySQL server version 8.0.30 it is getting failed and couldn't able to fix the issue till now.
ESCOD
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Sat 2022-12-31 08:37:07 GMT; 1h 7min ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 631823 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS (code=exited, status=1/FAILURE)
Process: 631795 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 631823 (code=exited, status=1/FAILURE)
Status: "Server shutdown complete"
Dec 31 08:37:06 fcg-db-mysql-oracle-lx-129.142 systemd[1]: Starting MySQL Server...
Dec 31 08:37:07 fcg-db-mysql-oracle-lx-129.142 mysqld[631823]: 2022-12-31T08:37:07.614931Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.30) starting as process 631823
Dec 31 08:37:07 fcg-db-mysql-oracle-lx-129.142 mysqld[631823]: 2022-12-31T08:37:07.614964Z 0 [ERROR] [MY-010338] [Server] Can't find error-message file '/usr/share/mysql-8.0/errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
Dec 31 08:37:07 fcg-db-mysql-oracle-lx-129.142 mysqld[631823]: 2022-12-31T08:37:07.620958Z 1 [ERROR] [MY-011011] [Server] Failed to find valid data directory.
Dec 31 08:37:07 fcg-db-mysql-oracle-lx-129.142 mysqld[631823]: 2022-12-31T08:37:07.621191Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
Dec 31 08:37:07 fcg-db-mysql-oracle-lx-129.142 mysqld[631823]: 2022-12-31T08:37:07.621215Z 0 [ERROR] [MY-010119] [Server] Aborting
Dec 31 08:37:07 fcg-db-mysql-oracle-lx-129.142 mysqld[631823]: 2022-12-31T08:37:07.621569Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.30) MySQL Community Server - GPL.
Dec 31 08:37:07 fcg-db-mysql-oracle-lx-129.142 systemd[1]: mysqld.service: Main process exited, code=exited, status=1/FAILURE
Dec 31 08:37:07 fcg-db-mysql-oracle-lx-129.142 systemd[1]: mysqld.service: Failed with result 'exit-code'.
Dec 31 08:37:07 fcg-db-mysql-oracle-lx-129.142 systemd[1]: Failed to start MySQL Server.
~
while from suggestions from some blogs i have tried mysqld --initialize --console, but it is also throwing error like below
mysqld: Can't create directory '/var/lib/mysql/' (OS errno 17 - File exists)
2022-12-31T18:12:49.257034Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.30) initializing of server in progress as process 3353
2022-12-31T18:12:49.257062Z 0 [Warning] [MY-010339] [Server] Using pre 5.5 semantics to load error messages from /usr/share/mysql-8.0/. If this is not intended, refer to the documentation for valid usage of --lc-messages-dir and --language parameters.
2022-12-31T18:12:49.257067Z 0 [ERROR] [MY-010342] [Server] Can't read from messagefile '/usr/share/mysql-8.0/errmsg.sys'
2022-12-31T18:12:49.257809Z 0 [ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it.
2022-12-31T18:12:49.257841Z 0 [ERROR] [MY-010119] [Server] Aborting
2022-12-31T18:12:49.257943Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.30) MySQL Community Server - GPL.
[fcgredim#fcg-db-mysql-oracle-lx-129 ~]$
Can anyone help on this?
1 . Run the below command to see if there are any errors in the file configuration.
mysqld --validate-config
Can't create directory '/var/lib/mysql/' (OS errno 17 - File exists)
2 . The above error indicates that something wrong with /var/lib/mysql/. Check if this path exists, and it has this permission drwx------ mysql mysql. (Also, if SElinx installed, check if it has the right label)

ERROR MY-011065 Server Unable to determine if daemon is running

everyone!
I have problem with installing mysql 8.0 server on linux ubuntu server 20.04.2 LTS.
I need to install this type of mysql-server 8.0.23 on linux ubuntu server 20.04.2 LTS!
I have tried:
https://www.youtube.com/watch?v=pQoUvmtq3_U&ab_channel=BeGeek
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
https://askubuntu.com/questions/643251/having-trouble-installing-and-removing-mysql-in-ubuntu
https://askubuntu.com/questions/1267636/cant-install-mysql-server-on-ubuntu-20-04-1-due-to-several-errors
MySQL my.cnf file - Found option without preceding group
https://askubuntu.com/questions/797312/either-mysql-wont-start-or-the-client-shows-error-found-option-without-precedi
https://serverfault.com/questions/305053/mysqld-sock-doesnt-exist
https://unix.stackexchange.com/questions/33433/font-encoding-in-terminal
https://linuxhint.com/install_mysql_ubuntu_2004/
and I have tried create file which is missing - that's not helped either way
I have new VDS with pure ubuntu server 20.04.2 LTS, is nothing there.
log: putty
Building dependency tree
Reading state information... Done
mysql-server is already the newest version (8.0.25-0ubuntu0.20.04.1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up mysql-server-8.0 (8.0.25-0ubuntu0.20.04.1) ...
Renaming removed key_buffer and myisam-recover options (if present)
mysqld will log errors to /var/log/mysql/error.log
2021-07-11T10:29:44.109433Z 0 [ERROR] [MY-011065] [Server] Unable to determine if daemon is running: No such file or directory (rc=0).
2021-07-11T10:29:44.117954Z 0 [ERROR] [MY-010946] [Server] Failed to start mysqld daemon. Check mysqld error log.
Warning: Unable to start the server.
Job for mysql.service failed because a fatal signal was delivered to the control process.
See "systemctl status mysql.service" and "journalctl -xe" for details.
invoke-rc.d: initscript mysql, action "start" failed.
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: signal) since Sun 2021-07-11 13:29:46 MSK; 44ms ago
Process: 10254 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Process: 10271 ExecStart=/usr/sbin/mysqld (code=killed, signal=KILL)
Main PID: 10271 (code=killed, signal=KILL)
Status: "Server startup in progress"
Jul 11 13:29:46 vm2107059480 systemd[1]: mysql.service: Main process exited, code=killed, status=9/KILL
Jul 11 13:29:46 vm2107059480 systemd[1]: mysql.service: Failed with result 'signal'.
Jul 11 13:29:46 vm2107059480 systemd[1]: Failed to start MySQL Community Server.
dpkg: error processing package mysql-server-8.0 (--configure):
installed mysql-server-8.0 package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-server-8.0; however:
Package mysql-server-8.0 is not configured yet.
dpkg: error processing package mysql-server (--configure):
dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
Errors were encountered while processing:
mysql-server-8.0
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
log: /var/log/mysql/error.log
2021-07-11T10:29:42.768169Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-07-11T10:29:46.023486Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.25-0ubuntu0.20.04.1) starting as process 10271
2021-07-11T10:29:46.151047Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-07-11T10:29:47.681827Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.25-0ubuntu0.20.04.1) starting as process 10290
2021-07-11T10:29:47.776960Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-07-11T10:29:53.765476Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.25-0ubuntu0.20.04.1) starting as process 10356
2021-07-11T10:29:58.511612Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-07-11T10:30:59.292200Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.25-0ubuntu0.20.04.1) starting as process 10386
2021-07-11T10:30:59.758603Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-07-11T10:31:01.640829Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.25-0ubuntu0.20.04.1) starting as process 10421
2021-07-11T10:31:01.695269Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-07-11T10:31:02.905736Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.25-0ubuntu0.20.04.1) starting as process 10443
2021-07-11T10:31:02.948849Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-07-11T10:31:04.145881Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.25-0ubuntu0.20.04.1) starting as process 10465
2021-07-11T10:31:04.183083Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-07-11T10:31:05.051672Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.25-0ubuntu0.20.04.1) starting as process 10487
2021-07-11T10:31:05.087005Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
I'm trying figure this out several days. Is someone know what I doing wrong?
Google doesn't helped me.
It works for me:
start swap.
dd if=/dev/zero of=/swapfile bs=1M count=1024
mkswap /swapfile
swapon /swapfile
docker start mysql

MySQL service won't start anymore because of OS error 105

Complete MySQL error Log: https://pastebin.com/20QX1ZSc
Overnight my MySQL install suddenly stopped working...
I am using ubuntu 20.04
systemctl:
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2021-05-13 14:50:18 CEST; 17min ago
Process: 4562 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Process: 4570 ExecStart=/usr/sbin/mysqld (code=exited, status=3)
Main PID: 4570 (code=exited, status=3)
Status: "Server startup in progress"
May 13 14:50:18 vault systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
May 13 14:50:18 vault systemd[1]: Stopped MySQL Community Server.
May 13 14:50:18 vault systemd[1]: mysql.service: Start request repeated too quickly.
May 13 14:50:18 vault systemd[1]: mysql.service: Failed with result 'exit-code'.
May 13 14:50:18 vault systemd[1]: Failed to start MySQL Community Server.
/var/log/mysql:
2021-05-13T12:50:18.017977Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.25-0ubuntu0.20.04.1) starting as process 4570
2021-05-13T12:50:18.032753Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-05-13T12:50:18.194467Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2021-05-13T12:50:18.428966Z 1 [Warning] [MY-012637] [InnoDB] 16384 bytes should have been read. Only 12288 bytes read. Retrying for the remaining bytes.
2021-05-13T12:50:18.604489Z 1 [Warning] [MY-012638] [InnoDB] Retry attempts for reading partial data failed.
2021-05-13T12:50:18.604910Z 1 [ERROR] [MY-012642] [InnoDB] Tried to read 16384 bytes at offset 16498688, but was only able to read 12288
2021-05-13T12:50:18.605273Z 1 [ERROR] [MY-012592] [InnoDB] Operating system error number 5 in a file operation.
2021-05-13T12:50:18.605645Z 1 [ERROR] [MY-012596] [InnoDB] Error number 5 means 'Input/output error'
2021-05-13T12:50:18.606374Z 1 [ERROR] [MY-012646] [InnoDB] File mysql.ibd: 'read' returned OS error 105. Cannot continue operation
2021-05-13T12:50:18.606762Z 1 [ERROR] [MY-012981] [InnoDB] Cannot continue operation.
looks like a data/ file corruption.try these steps:
remove the syslog entry under --> /etc/mysql/conf.d/mysqld_safe_syslog.cnf
backup & remove both ib_logfile0 & ib_logfile1 files under --> /var/lib/mysql
remove entry innodb_force_recovery = 1 from --> etc/mysql/my.cnf
run command --> sudo service mysql start
reference Forcing InnoDB Recovery

Mysql serivce can't start it, with the control process exited with error code problem

my os is Redhat8.
currtenly I install Mysql, version is "mysql Ver 8.0.13 for Linux on x86_64 (Source distribution)"
I use command "sudo yum install mysql, mysql-server"
But i get error when i want to start mysql services. I keep finding soluction, but still I don't know how to solved it.
Can anyone help me to look at it?
#--------------------------------------------------------------------------------------------------------
[yliu#rhlab1 ~]$ sudo 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.
# --------------------------------------------------------------------------------------------
[yliu#rhlab1 ~]$ sudo systemctl status mysqld
● mysqld.service - MySQL 8.0 database server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Wed 2020-02-19 12:12:15 AST; 15s ago
Process: 13080 ExecStopPost=/usr/libexec/mysql-wait-stop (code=exited, status=0/SUCCESS)
Process: 13052 ExecStart=/usr/libexec/mysqld --basedir=/usr (code=exited, status=1/FAILURE)
Process: 13015 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mysqld.service (code=exited, status=0/SUCCESS)
Process: 12991 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
Main PID: 13052 (code=exited, status=1/FAILURE)
Status: "SERVER_BOOTING"
Error: 2 (No such file or directory)
Feb 19 12:12:12 systemd[1]: Starting MySQL 8.0 database server...
Feb 19 12:12:15 systemd[1]: mysqld.service: Main process exited, code=exited, status=1/FAILURE
Feb 19 12:12:15 systemd[1]: mysqld.service: Failed with result 'exit-code'.
Feb 19 12:12:15 systemd[1]: Failed to start MySQL 8.0 database server.
# ----------------------------------------------------------------------------------------
[yliu#rhlab1 ~]$ sudo cat /var/log/mysql/mysqld.log | nl | tail -n 10
38 2020-02-19T15:48:25.492390Z 0 [System] [MY-010910] [Server] /usr/libexec/mysqld: Shutdown complete (mysqld 8.0.13) Source distribution.
39 2020-02-19T15:48:25.492468Z 0 [ERROR] [MY-010065] [Server] Failed to shutdown components infrastructure.
40 2020-02-19T16:12:13.332724Z 0 [System] [MY-010116] [Server] /usr/libexec/mysqld (mysqld 8.0.13) starting as process 13052
41 2020-02-19T16:12:13.585641Z 1 [ERROR] [MY-010781] [Server] Found ./mysql/index_stats.frm file in mysql schema. DD will create .ibd file with same name. Please rename table and start upgrade process again.
42 2020-02-19T16:12:13.585666Z 1 [ERROR] [MY-010336] [Server] Found .frm file with same name as one of the Dictionary Tables.
43 2020-02-19T16:12:13.585833Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
44 2020-02-19T16:12:13.585871Z 0 [ERROR] [MY-013236] [Server] Newly created data directory /var/lib/mysql/ is unusable. You can safely remove it.
45 2020-02-19T16:12:13.585881Z 0 [ERROR] [MY-010119] [Server] Aborting
46 2020-02-19T16:12:15.000469Z 0 [System] [MY-010910] [Server] /usr/libexec/mysqld: Shutdown complete (mysqld 8.0.13) Source distribution.
47 2020-02-19T16:12:15.000550Z 0 [ERROR] [MY-010065] [Server] Failed to shutdown components infrastructure.
My /etc/my.cnf.d/mysql-server.cnf information is:
[yliu#rhlab1 ~]$ sudo cat /etc/my.cnf.d/mysql-server.cnf
#
# This group are read by MySQL server.
# Use it for options that only the server (but not clients) should see
#
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/en/server-configuration-defaults.html
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mysqld according to the
# instructions in http://fedoraproject.org/wiki/Systemd
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
log-error=/var/log/mysql/mysqld.log
pid-file=/run/mysqld/mysqld.pid
I solved the problem, hope it will helpful for everyone who meet the same problem.
Base on the log:
41 2020-02-19T16:12:13.585641Z 1 [ERROR] [MY-010781] [Server] Found ./mysql/index_stats.frm file in mysql schema. DD will create .ibd file with same name. Please rename table and start upgrade process again.
42 2020-02-19T16:12:13.585666Z 1 [ERROR] [MY-010336] [Server] Found .frm file with same name as one of the Dictionary Tables.
43 2020-02-19T16:12:13.585833Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
44 2020-02-19T16:12:13.585871Z 0 [ERROR] [MY-013236] [Server] Newly created data directory /var/lib/mysql/ is unusable. You can safely remove it.
so we can remove all the files under /var/lib/mysql/
and then make sure the mysql file owner and group are mysql.
(Django) [yliu#rhlab1 ops]$ sudo ls -al /var/lib/ | grep mysql
drwxr-xr-x. 7 mysql mysql 4096 Feb 24 10:16 mysql
and then you can start mysqld again
sudo systemctl start mysqld

Mysql - Job for mysqld.service failed because the control process exited with error code

I installed mysql80-community-release-el7-1.noarch.rpm in my Centos 7 using this link successfully and I was trying to change my datadir using the following link. It worked fine till step 2 but at step 3 when i tried to start mysql using sudo systemctl start mysqld it gave me an error like this :
Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
I have tried the following solutions:
First
Second
But none of them seem to work for me. This is what my /var/log/mysqld.log file says :
2018-06-15T09:08:32.294452Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.11) initializing of server in progress as process 14593
2018-06-15T09:08:37.698910Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root#localhost: 7Y8An3/,r?ww
2018-06-15T09:08:40.729296Z 0 [System] [MY-013170] [Server] /usr/sbin/mysqld (mysqld 8.0.11) initializing of server has completed
2018-06-15T09:08:43.257796Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.11) starting as process 14695
2018-06-15T09:08:43.896289Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2018-06-15T09:08:43.936018Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.11' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Community Server - GPL.
2018-06-15T09:21:15.039285Z 0 [Warning] [MY-011068] [Server] The syntax 'validate password plugin' is deprecated and will be removed in a future release. Please use validate_password component instead.
2018-06-15T09:21:16.575642Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.11) MySQL Community Server - GPL
I am new to this.