Question
An error is reported when starting MySQL service, as shown below:
[root@node2 hadoop]# systemctl start mysqld.service
Job for mysqld.service failed because the control process exited with error code.
See "systemctl status mysqld.service" and "journalctl -xe" for details.
or
[root@node2 hadoop]# systemctl start mysqld.service
Job for mysqld.service failed because the control process exited with error code.
See "systemctl status mysqld.service" and "journalctl -xe" for details.
Solution
This is because the /var/lib/MySQL directory has insufficient permissions
[root@node2 hadoop]# cd /var/lib/mysql
[root@node2 mysql]# ll
all 167348
-rw-r-----. 1 root root 56 6月 19 20:00 auto.cnf
-rw-r-----. 1 mysql mysql 0 6月 19 20:01 binlog.index
-rw-------. 1 root root 1676 6月 19 20:00 ca-key.pem
-rw-r--r--. 1 root root 1112 6月 19 20:00 ca.pem
-rw-r--r--. 1 root root 1112 6月 19 20:00 client-cert.pem
-rw-------. 1 root root 1676 6月 19 20:00 client-key.pem
-rw-r-----. 1 root root 196608 6月 19 20:00 '#ib_16384_0.dblwr'
-rw-r-----. 1 root root 8585216 6月 19 20:00 '#ib_16384_1.dblwr'
-rw-r-----. 1 root root 3595 6月 19 20:00 ib_buffer_pool
-rw-r-----. 1 root root 12582912 6月 19 20:00 ibdata1
-rw-r-----. 1 root root 50331648 6月 19 20:00 ib_logfile0
-rw-r-----. 1 root root 50331648 6月 19 20:00 ib_logfile1
drwxr-x---. 2 root root 6 6月 19 20:00 '#innodb_temp'
drwxr-x---. 2 root root 6 6月 19 20:00 mysql
-rw-r-----. 1 root root 15728640 6月 19 20:00 mysql.ibd
drwxr-x---. 2 root root 8192 6月 19 20:00 performance_schema
-rw-------. 1 root root 1676 6月 19 20:00 private_key.pem
-rw-r--r--. 1 root root 452 6月 19 20:00 public_key.pem
-rw-r--r--. 1 root root 1112 6月 19 20:00 server-cert.pem
-rw-------. 1 root root 1676 6月 19 20:00 server-key.pem
-rw-r-----. 1 root root 16777216 6月 19 20:00 undo_001
-rw-r-----. 1 root root 16777216 6月 19 20:00 undo_002
Modify permissions and start MySQL
[root@node2 ~]# setenforce 0
[root@node2 ~]# chown -R mysql:mysql /var/lib/mysql
[root@node2 ~]# chmod -R 777 /var/lib/mysql
[root@node2 ~]# systemctl start mysqld.service
[root@node2 ~]# ps -ef |grep mysql
mysql 26627 1 4 23:57 ? 00:00:00 /usr/sbin/mysqld
root 26671 10438 0 23:57 pts/0 00:00:00 grep --color=auto mysql
[root@node2 ~]# cd /var/lib/mysql
[root@node2 mysql]# ll
all 190916
-rw-r-----. 1 mysql mysql 56 6月 19 23:57 auto.cnf
-rw-r-----. 1 mysql mysql 156 6月 19 23:57 binlog.000001
-rw-r-----. 1 mysql mysql 16 6月 19 23:57 binlog.index
-rwxrwxrwx. 1 mysql mysql 1680 6月 19 23:50 ca-key.pem
-rwxrwxrwx. 1 mysql mysql 1112 6月 19 23:50 ca.pem
-rwxrwxrwx. 1 mysql mysql 1112 6月 19 23:50 client-cert.pem
-rwxrwxrwx. 1 mysql mysql 1676 6月 19 23:50 client-key.pem
-rwxrwxrwx. 1 mysql mysql 196608 6月 19 23:57 '#ib_16384_0.dblwr'
-rwxrwxrwx. 1 mysql mysql 8585216 6月 19 23:50 '#ib_16384_1.dblwr'
-rwxrwxrwx. 1 mysql mysql 6059 6月 19 23:50 ib_buffer_pool
-rwxrwxrwx. 1 mysql mysql 12582912 6月 19 23:57 ibdata1
-rwxrwxrwx. 1 mysql mysql 50331648 6月 19 23:57 ib_logfile0
-rwxrwxrwx. 1 mysql mysql 50331648 6月 19 23:50 ib_logfile1
-rw-r-----. 1 mysql mysql 12582912 6月 19 23:57 ibtmp1
drwxrwxrwx. 2 mysql mysql 187 6月 19 23:57 '#innodb_temp'
drwxrwxrwx. 2 mysql mysql 143 6月 19 23:50 mysql
-rwxrwxrwx. 1 mysql mysql 27262976 6月 19 23:57 mysql.ibd
srwxrwxrwx. 1 mysql mysql 0 6月 19 23:57 mysql.sock
-rw-------. 1 mysql mysql 6 6月 19 23:57 mysql.sock.lock
drwxrwxrwx. 2 mysql mysql 8192 6月 19 23:50 performance_schema
-rwxrwxrwx. 1 mysql mysql 1676 6月 19 23:50 private_key.pem
-rwxrwxrwx. 1 mysql mysql 452 6月 19 23:50 public_key.pem
-rwxrwxrwx. 1 mysql mysql 1112 6月 19 23:50 server-cert.pem
-rwxrwxrwx. 1 mysql mysql 1680 6月 19 23:50 server-key.pem
drwxrwxrwx. 2 mysql mysql 28 6月 19 23:50 sys
-rwxrwxrwx. 1 mysql mysql 16777216 6月 19 23:57 undo_001
-rwxrwxrwx. 1 mysql mysql 16777216 6月 19 23:57 undo_002
[root@node2 mysql]#
Note:
- Setenforce 0 is used to solve [InnoDB] Operating system error number 13 in a file operation.
- Directory permissions must be set to 777, just 755 will also cause an error
Read More:
- [Solved] Job for mysqld.service failed because the control process exited with error code
- [Solved] mariadb Startup Error: Job for mariadb.service failed because the control process exited with error code.
- [Solved] Rabbitmq Startup Error: Job for rabbitmq-server.service failed because the control process exited with
- ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’
- MYSQL8 Startup Error: mysqld_safe error: log-error set to ‘/var/log/mariadb/mariadb.log‘
- How to Solve MYSQL Error: Failed to start MySQL 8.0 database server
- Centos7 Initialize mysql Error: Could not open file ‘/usr/local/mysql/log/mysqld.log‘ for error logging: Per
- How to Solve mysqld — console command error
- Dbeaver Import SQL File Error: Error executing process Process failed (exit code = 1). See error log. Process failed (exit code = 1). See error log.
- MySQL startup error: vcruntime140_1.dll cannot be found, unable to continue code execution
- MYSQL 5.7 Error Code: 1290. The MySQL server is running with the –secure-file-priv option so it..
- ERROR: mysqld failed while attempting to check config [How to Solve]
- [Solved] MySQL Startup Error: The server quit without updating PID file
- [Solved] CentOS installs MySQL and starts MySQL with error 2002 (HY000)
- [Solved] sqoop Import Datas to mysql error: ERROR tool.ExportTool: Error during export: Export job failed
- MySql Install Error: Can‘t connect to local MySQL server through socket ‘/tmp/mysql.sock‘
- [Solved] ERROR 2002 (HY000): Can’t connect to local MySQL server through socket’/var/lib/mysql/mysql.sock’ (2)
- (Fixed) workbench MySQL Error Code: 2013. Lost connection to MySQL server during query
- [Solved] ERROR: child process failed, exited with error number 14 (error number 1, error number 100)
- [Solved] MYSQL Error: ERROR! MySQL server PID file could not be found!