1. 程式人生 > >MySQL is running but PID file could not be found 解決方案

MySQL is running but PID file could not be found 解決方案

今天碰到一個問題,伺服器異常關閉,mysql無法啟動,檢視mysql 狀態service mysqld status都提示:MySQL is running but PID file could not be found。
解決方法:

  1. 使用ps -elf |grep mysql 查詢mysql的程序,瞭解到pid檔案在 /usr/local/var 目錄下, 記一下,等會需要這個目錄
    在這裡插入圖片描述

  2. 打算先停掉服務,再重啟服務

    service mysqld stop

提示:MySQL manager or server PID file could not be found!
解決: 使用 ps -elf |grep mysql |grep -v grep


將查詢出來的和mysql 相關的程序全部kill 掉,再重啟,使用命令:

service  mysqld start
  1. 然而還是不行,一直停留在
    在這裡插入圖片描述
    檢視狀態
    在這裡插入圖片描述
    於是去把lock 先刪掉
[[email protected] ~]# cd  /var/lock/subsys/
[[email protected] subsys]# ls
crond  local  mysql  network  nscd  ntpd  rsyslog  sshd
[[email protected] subsys]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
[
[email protected]
subsys]# rm -rf ./mysql [[email protected] subsys]# ls crond local network nscd ntpd rsyslog sshd

檢視mysql 狀態service mysqld status都提示:MySQL is running but PID file could not be found
這個時候去把 mysql 中 data 目錄下的 mysql-bin.index 檔案找到,然後刪除

[[email protected] subsys]# find / -name mysql-bin.index
/usr/local/var/mysql-bin.index
[
[email protected]
subsys]# rm -rf /usr/local/var/mysql-bin.index

然後找到 並 kill 所有關於 mysql 或者 mysqld 的程序

ps -aux | grep mysql
  1. 到這一般來說基本可以了,但是啟動mysql服務時候還是出現MySQL is running but PID file could not be found
    這時候就要另闢蹊徑 了。
    剛第一步的時候說到,pid 檔案所在的目錄,開啟這個目錄,我們看到確實沒有找到 xxxxx.pid 檔案,但是有一個 xxxx.err檔案,於是開啟看一下,都有哪些執行錯誤記錄,然後找到了最關鍵的一條:
181121 10:48:28 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
 /usr/local/libexec/mysqld: Disk is full writing './mysql-bin.~rec~' (Errcode: 28). Waiting for someone to free space... (Expect up to 60 secs delay for server to continue after freeing disk space)
 /usr/local/libexec/mysqld: Retry in 60 secs. Message reprinted in 600 secs
 /usr/local/libexec/mysqld: Retry in 60 secs. Message reprinted in 600 secs
 /usr/local/libexec/mysqld: Retry in 60 secs. Message reprinted in 600 secs
 /usr/local/libexec/mysqld: Retry in 60 secs. Message reprinted in 600 secs
181121 11:00:31 mysqld_safe mysqld from pid file /usr/local/var/iZ253su9kjuZ.pid ended

那就是 Disk is full writing './mysql-bin.~rec~' (Errcode: 28). Waiting for someone to free space...
我進mysql資料目錄檢視,發現有很多以前的二進位制日誌,所以打算清空2017年前所有的二進位制日誌。
解決辦法:
先rm刪除binlog日誌,再purge binary logs to '具體的binlog’刪除。
注意:purge binary logs to 'mysql-bin.00003’表示清理mysql-bin.00003之前的所有binlog,但不包括mysql-bin.00003本身。
注意:如果只rm,不purge,重啟mysql的話,會報錯的,mysql就起不來了。所以rm刪除後,需要及時執行purge命令。


[[email protected] var]# purge binary logs to 'mysql-bin.00034'

於是就OK了,mysql服務終於重新啟動了,資料也沒有丟失

[[email protected] var]# service mysqld status
MySQL is not running                                       [ʧ▒▒]
[[email protected] var]# service mysqld start
Starting MySQL.                                            [ȷ▒▒]
[[email protected] var]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.51-log Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use mysql
Database changed

補充一個mysql修改使用者密碼的命令
在這裡插入圖片描述

相關推薦

MySQL is running but PID file could not be found 解決方案

今天碰到一個問題,伺服器異常關閉,mysql無法啟動,檢視mysql 狀態service mysqld status都提示:MySQL is running but PID file could not be found。 解決方法: 使用ps -elf |

MySQL is running but PID file could not be found(解決方法)

啟動MySQL時報錯: [[email protected] /]# service mysqld status MySQL is running but PID file could not be found    [失敗]   解決辦法: 找到並kill掉

MySQL server PID file could not be found! 解決辦法 (李作強)

MySQL server PID file could not be found! 解決辦法 1.可能是/usr/local/mysql/data/rekfan.pid檔案沒有寫的許可權 解決方法 :給予許可權,執行 “chown -R mysql:mysql /var/data” “

MySQL server PID file could not be found! 解決辦法

MySQL server PID file could not be found! 解決辦法 1.可能是/usr/local/mysql/data/rekfan.pid檔案沒有寫的許可權  解決方法 :給予許可權,執行 “chown -R mysql:mysql /var/data

遇到的問題---mysql 啟動錯誤-server PID file could not be found

[[email protected] var]# service mysqld stop MySQL manager or server PID file could not be found!       [FAILED] 解決辦法: 首先檢視一下程序 [[em

MySQL server PID file could not be found!

blog 做的 所有 寫的權限 如果 rate data 重啟 一個個 重啟mysql提示MySQL server PID file could not be found! Starting MySQL...The server quit without updating

mysql報錯 MySQL server PID file could not be found The server quit without updating PID file (/var/l

執行mysql重啟命令突然報錯: 後面的/var/lib/mysql/192.168.1.139.pid給了我們提示 我們進入/var/lib/mysql資料夾  發現了一個好東西  192.168.1.139.err(不用想錯誤資訊肯定在這裡面) 檢視日

mysql 重啟過程出現MySQL server PID file could not be found![失敗]

service mysql restartMySQL server PID file could not be found![失敗]Starting MySQL...The server quit without updating PID file (/usr/local/m

Docker容器啟動lnmp環境下的mysql服務時報"MySQL server PID file could not be found"錯誤解決辦法

我在自己的mac筆記本上裝了一個docker,並在docker容器中安裝了lnmp環境,經常會遇到在使用"lnmp restart"命令啟動lnmp服務的時候,mysql服務啟動失敗,啟動日誌: Stoping LNMP... Stoping nginx... nginx is not running.

CentOS MySQL 提示:MySQL server PID file could not be found!

今天在連線測試環境MySQL 時,突然出現如下的錯誤情況: [[email protected] log]# service mysql restart MySQL server PID file could not be found!

mysql報錯問題解決MySQL server PID file could not be found!

MySQL server PID file could not be found!  無法啟動mysql服務 # service mysqld start MySQL server PID file could not be found!                

eclipse儲存jsp頁面的時候出現save could not be completed解決方案

Eclipse中新建一個jsp頁面檔案預設的字元編碼是ISO-8859-1: 如果頁面有中文的話,儲存的時候會出現下面的錯誤: 這時只需要把上面的三個iso-8859-1換成utf-8即可。 問題解決,可是下一次遇到這個問題又得重新換一次,麻煩,所以下面介紹一個一勞永逸的

git使用採坑-The project you were looking for could not be found 解決方式

git使用採坑-The project you were looking for could not be found 解決方式

mysql啟動報錯,提示MySQL is not running, but PID file exists

mysql所在機器關機重啟後,mysql無法啟動,啟動一直報錯MySQL is not running, but PID file exists, 嘗試了所有的啟動方式,都無法啟動,在使用mysqld

Kettle 連線 oracle 報錯:could not be found, make sure the 'Oracle' driver (jar file) is installed.

報錯如下:Driver class 'oracle.jdbc.driver.OracleDriver' could not be found, make sure the 'Oracle' driver (jar file) is installed.oracle.jdbc.

Eclipse離線安裝activiti報錯,缺少jar包(requires 'org.eclipse.emf 2.6.0' but it could not be found

eclipse安裝activiti報錯,缺少jar包。具體報錯如下: Cannot complete the install because one or more required items could not be found. Software being installed: Activi

minigui 3.2.0:對mgncs剪裁遇到的問題error: The pkg-config script could not be found or is too old.

考慮到嵌入式平臺的儲存和執行空間都有限,在向目標平臺移植時肯定要對minigui及其元件進行剪裁,刪除掉不需要的功能和特性,以縮小程式體積,對mgncs做剪裁時遇到了一個非常奇怪的問題,雖然解決了,但現在也沒找到根本原因: 根據configure --help的提示使用--enable-

composer在update時提示file could not be downloaded: SSL operation failed with code 1. OpenSSL Error messages: error:1407742E:SSL routines:SSL23_GET_SERVER

在開發的時候,需要把依賴的服務更新到最新,然後 手動composer update一下,提示如下: 1 failed) Update failed (The "e "https://api.github.com/repos/illuminate/validation/zipba

格式化namenode時:Error: JAVA_HOME is not set and could not be found.

1.格式化namenode 命令:hdfs namenode -format         如果Error: JAVA_HOME is not set and could not be found. &nb

Hadoop初次啟動時 程序啟動失敗 提示JAVA_HOME is not set and could not be found

初次配置好Hadoop偽分散式式之後,啟動./sbin/start-all.sh  命令發現程序啟動失敗, 如下圖所示 jps 命令檢視程序 發現namenode  datanode 均沒有啟動  提示 JAVA_HOME is not set and could no