欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

[ERROR] Can't start server: can't check PID filepath: No such file or directory

程序员文章站 2022-07-15 16:42:35
...

mysql 5.7启动不了

这个问题一般都是pid目录没创建或者没有目录权限
解决办法:创建pid目录并给予权限或修改pid目录(参看配置文件my.cnf默认为/etc/my.cnf)至mysql目录下

  • 启动方法 由于密码忘记了(–skip-grant-tables)
[[email protected] ~]# /usr/local/mysql/bin/mysqld_safe --skip-grant-tables --user=mysql &
[1] 24106
[[email protected] ~]# 2020-02-03T18:17:41.676610Z mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
2020-02-03T18:17:41.706108Z mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
2020-02-03T18:17:42.156327Z mysqld_safe mysqld from pid file /var/run/mariadb/mariadb.pid ended

[1]+  Done                    /usr/local/mysql/bin/mysqld_safe --skip-grant-tables --user=mysql
###查看端口状态发现没起来
 [[email protected] ~]#netstat -nutpl |grep 3306
 [[email protected] ~]#
  • 查看故障日志
    故障日志存储位置请参考/etc/my.cnf中的log-error参数
### 查看配置文件参数 cat查看vi more等命令
[[email protected] ~]# vi /etc/my.cnf
[mysqld]
datadir=/usr/local/mysql/data
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd

[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid

#
# include all files from the config directory
#
#!includedir /etc/my.cnf.d
####日志报错信息###############
[[email protected] ~]# cat /var/log/mariadb/mariadb.log

2020-02-03T18:17:41.948351Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-02-03T18:17:41.948457Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2020-02-03T18:17:41.948567Z 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.7.29) starting as process 24256 ...
2020-02-03T18:17:41.955264Z 0 [Note] InnoDB: PUNCH HOLE support available
2020-02-03T18:17:41.955304Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2020-02-03T18:17:41.955309Z 0 [Note] InnoDB: Uses event mutexes
2020-02-03T18:17:41.955312Z 0 [Note] InnoDB: GCC builtin __sync_synchronize() is used for memory barrier
2020-02-03T18:17:41.955316Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-02-03T18:17:41.955319Z 0 [Note] InnoDB: Using Linux native AIO
2020-02-03T18:17:41.955700Z 0 [Note] InnoDB: Number of pools: 1
2020-02-03T18:17:41.955832Z 0 [Note] InnoDB: Using CPU crc32 instructions
2020-02-03T18:17:41.958114Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2020-02-03T18:17:41.969536Z 0 [Note] InnoDB: Completed initialization of buffer pool
2020-02-03T18:17:41.973272Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2020-02-03T18:17:41.986619Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2020-02-03T18:17:41.999938Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2020-02-03T18:17:41.999960Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2020-02-03T18:17:42.000076Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2020-02-03T18:17:42.020491Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2020-02-03T18:17:42.021802Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2020-02-03T18:17:42.021820Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2020-02-03T18:17:42.022080Z 0 [Note] InnoDB: Waiting for purge to start
2020-02-03T18:17:42.072756Z 0 [Note] InnoDB: 5.7.29 started; log sequence number 2629979
2020-02-03T18:17:42.073073Z 0 [Note] Plugin 'FEDERATED' is disabled.
2020-02-03T18:17:42.089236Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2020-02-03T18:17:42.089291Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
2020-02-03T18:17:42.092945Z 0 [Warning] CA certificate ca.pem is self signed.
2020-02-03T18:17:42.093091Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
2020-02-03T18:17:42.093982Z 0 [Note] InnoDB: Loading buffer pool(s) from /usr/local/mysql/data/ib_buffer_pool
2020-02-03T18:17:42.101517Z 0 [Note] InnoDB: Buffer pool(s) load completed at 200203 13:17:42
2020-02-03T18:17:42.101931Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2020-02-03T18:17:42.102132Z 0 [Note] IPv6 is available.
2020-02-03T18:17:42.102162Z 0 [Note]   - '::' resolves to '::';
2020-02-03T18:17:42.102230Z 0 [Note] Server socket created on IP: '::'.
2020-02-03T18:17:42.104243Z 0 [ERROR] Can't start server: can't check PID filepath: No such file or directory

  • 创建pid目录
[[email protected] ~]# mkdir -p /var/run/mariadb/
[[email protected] ~]# chown mysql.mysql /var/run/mariadb/ -R
  • 重新启动
 [[email protected] ~]# /usr/local/mysql/bin/mysqld_safe --skip-grant-tables --user=mysql &
[1] 24488
[[email protected] ~]# 2020-02-03T18:24:19.611951Z mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
2020-02-03T18:24:19.643658Z mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
[[email protected] ~]# netstat -nutpl |grep 330
tcp6       0      0 :::3306                 :::*                    LISTEN      24638/mysqld        
[[email protected] ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.29 MySQL Community Server (GPL)
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>