Error information
Login database error:`
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/ mysql.sock ‘ (2 “No such file or directory”)`
Service restart error: job for mariadb.service failed because the control process exited with error code. See "systemctl status mariadb.service " and "journalctl -xe" for details.
View service status information: ` systemctl status mariadb.service
● mariadb.service – MariaDB 10.1 database server
Loaded: loaded (/usr/lib/systemd/system/ mariadb.service ; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Mon 2019-04-15 17:16:38 UTC; 4s ago
Process: 2864 ExecStartPre=/usr/libexec/mysql-prepare-db-dir %n (code=exited, status=1/FAILURE)
Process: 2841 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
Apr 15 17:16:37 xiandian systemd[1]: Starting MariaDB 10.1 database server…
Apr 15 17:16:38 xiandian mysql-prepare-db-dir[2864]: Database MariaDB is not initialized, but the directory /var/lib/mysql is not empty…e done.
Apr 15 17:16:38 xiandian mysql-prepare-db-dir[2864]: Make sure the /var/lib/mysql is empty before running mysql-prepare-db-dir.
Apr 15 17:16:38 xiandian systemd[1]: mariadb.service : control process exited, code=exited status=1
Apr 15 17:16:38 xiandian systemd[1]: Failed to start MariaDB 10.1 database server.
Apr 15 17:16:38 xiandian systemd[1]: Unit mariadb.service entered failed state.
Apr 15 17:16:38 xiandian systemd[1]: mariadb.service failed.
Hint: Some lines were ellipsized, use -l to show in full.`
The error message of restart service log: ` APR 15 17:16:21 Xiandian MySQL prepare DB dir: database MariaDB is not initialized, but the directory/var/lib/MySQL is not empty, so initialization cannot be done
Apr 15 17:16:21 mysql-prepare-db-dir: Make sure the /var/lib/mysql is empty before running mysql-prepare-db-dir.
Apr 15 17:16:21 systemd: mariadb.service : control process exited, code=exited status=1
Apr 15 17:16:21 systemd: Failed to start MariaDB 10.1 database server.
Apr 15 17:16:21 systemd: Unit mariadb.service entered failed state.
Apr 15 17:16:21 systemd: mariadb.service failed.`
You can see that the error message indicates that the database is not initialized, but/var/lib/MySQL is not empty, so it cannot be initialized.
Take a look at the directory permissions
ll /var/lib/
d---------. 11 mysql mysql 4096 May 4 2018 mysql
The MySQL permission is 0, which causes the startup file sock file cannot be written in
Restart, give the directory permission 755
Chmod 755/var/lib/MySQL/ code>
and then restart the MySQL service
systemctl restart mariadb.service
PS - e | grep - I MySQL
3191?00:00:02 mysqld
starts normally
Reproduced in: https://blog.51cto.com/9103824/2378808
Read More:
- Solution to error 2002 (HY000) in MySQL
- ERROR 2002 (HY000): Can’t connect to MySQL server on ‘localhost’ (10061)
- Error 2003 (HY000): can’t connect to MySQL server on ‘localhost’ (10061)
- MYSQL login error: mysqladmin: connect to server at’localhost’ failed
- After installing MySQL again under Linux, the solution of ‘MySQL module failed to start’ appears
- About error 1005 (HY000) in MySQL: can’t create table ‘_______ ‘(errno: 150) fool’s plan
- Mysql start slave error 1201 (HY000)
- Solve MySQL error 2002 (HY000)
- ERROR 2005 (HY000): Unknown MySQL server host
- Error 2005 (HY000) unkonw MySQL server host…
- [MySQL] error 1396 (HY000): Operation create user failed for ‘MySQL’ @’localhost ‘
- ERROR 2000 (HY000): Unknown MySQL error
- SQL Server 2008 18456 error and SA unable to login solution
- SQL exception handling – MySQL error 1005 (HY000): can’t create table ‘TMP’ (errno: 13)
- [Four Solutions] FTP Login Error: 530 Login incorrect.Login failed”
- MySQL error 1205 (HY000): lock wait timeout exceeded; try restarting transaction
- Solution to 1030 got error 28 from storage engine in MySQL
- MySQL uses net start MySQL startup prompt (failed to start, the service did not report any error)
- Solution to communication link failure with error in idea startup project
- MySQL error: error 1010 (HY000) when deleting database