How to solve the problem that MySQL cannot start because it cannot create PID

How to solve the problem that MySQL cannot start because it cannot create PID

Problem Description

The MySQL startup error message is as follows:

Starting mysqld (via systemctl):
 Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details. [FAILED]

Follow the prompts and run systemctl status mysqld.service and journalctl -xe to check the reason why the service failed to start.

[root@ ~]# systemctl status mysqld.servicemysqld.service - SYSV: MySQL database server.Loaded: loaded (/etc/rc.d/init.d/mysqld)Active: failed (Result: exit-code) since Wed 2016-01-20 18:26:57 CST; 40s agoDocs: man:systemd-sysv-generator(8)Process: 2979 ExecStart=/etc/rc.d/init.d/mysqld start (code=exited, status=1/FAILURE)Jan 20 18:26:56 spark01 systemd[1]: Starting SYSV: MySQL database server….Jan 20 18:26:57 spark01 mysqld[2979]: MySQL Daemon failed to start.Jan 20 18:26:57 spark01 mysqld[2979]: Starting mysqld: [FAILED]Jan 20 18:26:57 spark01 systemd[1]: mysqld.service: control process exited, code=exited status=1Jan 20 18:26:57 spark01 systemd[1]: Failed to start SYSV: MySQL database server..Jan 20 18:26:57 spark01 systemd[1]: Unit mysqld.service entered failed state.Jan 20 18:26:57 spark01 systemd[1]: mysqld.service failed.[root@ ~]# journalctl -xeUnit session-2.scope has begun starting up.Jan 20 18:26:48 spark01 sshd[2916]: pam_unix(sshd:session): session opened for user spark by (uid=0)Jan 20 18:26:52 spark01 su[2944]: (to root) spark on pts/1Jan 20 18:26:52 spark01 su[2944]: pam_unix(su-l:session): session opened for user root by spark(uid=1000)Jan 20 18:26:56 spark01 polkitd[909]: Registered Authentication Agent for unix-process:2974:117137 (system bus name :1.25Jan 20 18:26:56 spark01 systemd[1]: Starting SYSV: MySQL database server….— Subject: Unit mysqld.service has begun start-up— Defined-By: systemd— Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel—— Unit mysqld.service has begun starting up.Jan 20 18:26:57 spark01 mysqld[2979]: MySQL Daemon failed to start.Jan 20 18:26:57 spark01 mysqld[2979]: Starting mysqld: [FAILED]Jan 20 18:26:57 spark01 systemd[1]: mysqld.service: control process exited, code=exited status=1Jan 20 18:26:57 spark01 systemd[1]: Failed to start SYSV: MySQL database server..— Subject: Unit mysqld.service has failed— Defined-By: systemd— Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel—— Unit mysqld.service has failed.—— The result is failed.Jan 20 18:26:57 spark01 systemd[1]: Unit mysqld.service entered failed state.Jan 20 18:26:57 spark01 systemd[1]: mysqld.service failed.Jan 20 18:26:57 spark01 polkitd[909]: Unregistered Authentication Agent for unix-process:2974:117137 (system bus name :1.

This information does not provide the real reason why the service startup failed.

View the MySQL warning log:

2016-01-20T10:00:19.935771Z 0 [ERROR] /usr/sbin/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 2 - No such file or directory)2016-01-20T10:00:19.935795Z 0 [ERROR] Can't start server: can't create PID file: No such file or directory160120 18:00:20 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

Solution

The MySQL service cannot create a pid file when it starts.

Check in the terminal whether the directory exists. If not, create it manually:

[root@ ~]# mkdir -p /var/run/mysqld/

Try to start the MySQL service again, the error is as follows:

Starting mysqld (via systemctl):
 Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details. [FAILED]

View the MySQL warning log:

2016-01-20T10:28:37.183387Z 0 [ERROR] /usr/sbin/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 13 - Permission denied)2016-01-20T10:28:37.183431Z 0 [ERROR] Can't start server: can't create PID file: Permission denied160120 18:28:37 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended160120 18:32:06 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

The permissions are incorrect. The owner and group of /var/run/mysqld/ are still root. MySQL cannot modify the owner and group of the directory after creating files in it.

[root@ ~]# ls -ld /var/run/mysqld/drwxr-xr-x 2 root root 40 Jan 20 18:28 /var/run/mysqld/
[root@ ~]# chown mysql.mysql /var/run/mysqld/
[root@ ~]# /etc/init.d/mysqld start Starting mysqld (via systemctl): [ OK ]

Summarize

The above is the full content of this article. I hope that the content of this article can bring some help to your study or work. If you have any questions, you can leave a message to communicate. Thank you for your support of 123WORDPRESS.COM.

You may also be interested in:
  • Python chat room with interface implementation example code (tkinter, Mysql, Treading, socket)
  • ERROR 2002 (HY000): Can't connect to local MySQL server through socket ''/tmp/mysql.sock''
  • Can't connect to local MySQL through socket ''/tmp/mysql.sock'' solution
  • Java+jdbc+mysql+socket to build a LAN chat room
  • Java Socket+mysql to implement simple file uploader code
  • Detailed explanation of the function of mysql socket file
  • MySQL error ERROR 2002 (HY000): Can't connect to local MySQL server through socket
  • MySQL HandlerSocket plugin installation and configuration tutorial
  • In-depth analysis of the reason why the error "The server quit without updating PID file" is reported when MySQL is started
  • MySQL startup error MySQL server PID file could not be found
  • Solution to the problem of missing pid file after Mysql crashes and cannot be restarted
  • Solutions to MySQL PID file loss related errors
  • mysql: Can't start server: can't create PID file: No space left on device
  • MySQL Tips: Solution to the problem of server quit without updating PID file
  • linux mysql error: MYSQL: The server quit without updating PID file
  • Solution for Starting MySQL.Manager of pid-file quit without updating file.[FAILED]
  • Detailed explanation of pid and socket in MySQL

<<:  JavaScript implements simple calculator function

>>:  Docker's health detection mechanism

Recommend

Solution - BASH: /HOME/JAVA/JDK1.8.0_221/BIN/JAVA: Insufficient permissions

1) Enter the folder path where the jdk file is st...

Sample code for implementing DIV suspension with pure CSS (fixed position)

The DIV floating effect (fixed position) is imple...

MySql login password forgotten and password forgotten solution

Method 1: MySQL provides a command line parameter...

How to view the IP address of the Docker container

I always thought that Docker had no IP address. I...

HTML table markup tutorial (43): VALIGN attribute of the table header

In the vertical direction, you can set the alignm...

CSS3 animation – steps function explained

When I was looking at some CSS3 animation source ...

Docker configures the storage location of local images and containers

Use the find command to find files larger than a ...

Detailed explanation of how to write mysql not equal to null and equal to null

1. Table structure 2. Table data 3. The query tea...

Solution to Nginx SSL certificate configuration error

1. Introduction When a web project is published o...

Detailed tutorial on deploying SpringBoot + Vue project to Linux server

Preface Let me share with you how I deployed a Sp...

Javascript operation mechanism Event Loop

Table of contents 1. Four concepts 1. JavaScript ...

JavaScript knowledge: Constructors are also functions

Table of contents 1. Definition and call of const...

Two ways to export csv in win10 mysql

There are two ways to export csv in win10. The fi...

How to draw the timeline with vue+canvas

This article example shares the specific code of ...