MySQL5.7が立ち上がらないエラーが出た。

mysqlが立ち上がらないエラーが出た。

#service mysql start
Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
#systemctl status mysql.service

# systemctl status mysql.service
● mysql.service - LSB: Start and stop the mysql database server daemon
   Loaded: loaded (/etc/init.d/mysql)
   Active: failed (Result: exit-code) since ...
     Docs: man:systemd-sysv-generator(8)
  Process: 10495 ExecStart=/etc/init.d/mysql start (code=exited, status=1/FAILURE)

# less /var/log/mysqld.log

2017-07-10T15:53:03.811572Z 0 [Note] Server socket created on IP: '::'.
2017-07-10T15:53:03.821949Z 0 [ERROR] /usr/sbin/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 2 - No such file or directory)
2017-07-10T15:53:03.821979Z 0 [ERROR] Can't start server: can't create PID file: No such file or directory
2017-07-10T15:56:26.571644Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more d
etails).

pid-fileがかけませんというエラーだった。

# less /etc/my.cnf

[mysqld]

...
pid-file=/var/run/mysqld/mysqld.pid
...

ファイルをかけるようにする。

# mkdir /var/run/mysqld
# chown mysql:mysql /var/run/mysqld
# service mysqld start

qiita.com