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

Detailed explanation of map overlay in openlayers6

1. Overlay Overview Overlay means covering, as th...

Introduction to CSS BEM Naming Standard (Recommended)

1 What is BEM Naming Standard Bem is the abbrevia...

CSS to achieve compatible text alignment in different browsers

In the front-end layout of the form, we often nee...

Detailed explanation of the installation process of Jenkins on CentOS 7

Install Jenkins via Yum 1. Installation # yum sou...

How to enable Swoole Loader extension on Linux system virtual host

Special note: Only the Swoole extension is instal...

MySQL efficient query left join and group by (plus index)

mysql efficient query MySQL sacrifices group by t...

Elementui exports data to xlsx and excel tables

Recently, I learned about the Vue project and cam...

Docker beginners' first exploration of common commands practice records

Before officially using Docker, let's first f...

MySQL variable declaration and stored procedure analysis

Declaring variables Setting Global Variables set ...

Vue project realizes paging effect

The paging effect is implemented in the vue proje...

MySQL optimization query_cache_limit parameter description

query_cache_limit query_cache_limit specifies the...

How to create a swap partition file in Linux

Introduction to Swap Swap (i.e. swap partition) i...