CentOS7下MySQL服務啟動失敗原因及解決方法

来源:https://www.cnblogs.com/bieyaoxiguan/archive/2019/08/22/11394556.html
-Advertisement-
Play Games

在重啟阿裡的CentOS7伺服器後,重啟MySQL 出現錯誤 按照提示查看錯誤信息 [root@djaljdw ~]# systemctl status mysqld.service [root@djaljdw ~]# journalctl -xe 發現裡面並沒有提供有用的錯誤信息 所以去查看mys ...


在重啟阿裡的CentOS7伺服器後,重啟MySQL 出現錯誤

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]

按照提示查看錯誤信息

[root@djaljdw ~]# systemctl status mysqld.service

● mysqld.service - SYSV: MySQL database server.
   Loaded: loaded (/etc/rc.d/init.d/mysqld; bad; vendor preset: disabled)
   Active: failed (Result: exit-code) since Thu 2019-08-22 14:42:39 CST; 1min 25s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 2427 ExecStart=/etc/rc.d/init.d/mysqld start (code=exited, status=1/FAILURE)

Aug 22 14:42:37 izw91diu854rguz systemd[1]: Starting SYSV: MySQL database server....
Aug 22 14:42:39 izw91diu854rguz mysqld[2427]: MySQL Daemon failed to start.
Aug 22 14:42:39 izw91diu854rguz mysqld[2427]: Starting mysqld:  [FAILED]
Aug 22 14:42:39 izw91diu854rguz systemd[1]: mysqld.service: control process exited, code=exited status=1
Aug 22 14:42:39 izw91diu854rguz systemd[1]: Failed to start SYSV: MySQL database server..
Aug 22 14:42:39 izw91diu854rguz systemd[1]: Unit mysqld.service entered failed state.
Aug 22 14:42:39 izw91diu854rguz systemd[1]: mysqld.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

[root@djaljdw ~]#  journalctl -xe

-- 
-- Unit 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/1
Jan 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.25
Jan 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=1
Jan 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.

發現裡面並沒有提供有用的錯誤信息

所以去查看mysql日誌信息(/var/log/mysqld.log)

190822 14:44:42 [Note] Plugin 'FEDERATED' is disabled.
190822 14:44:42 InnoDB: The InnoDB memory heap is disabled
190822 14:44:42 InnoDB: Mutexes and rw_locks use GCC atomic builtins
190822 14:44:42 InnoDB: Compressed tables use zlib 1.2.3
190822 14:44:42 InnoDB: Using Linux native AIO
190822 14:44:42 InnoDB: Initializing buffer pool, size = 128.0M
190822 14:44:42 InnoDB: Completed initialization of buffer pool
190822 14:44:42 InnoDB: highest supported file format is Barracuda.
InnoDB: The log sequence number in ibdata files does not match
InnoDB: the log sequence number in the ib_logfiles!
190822 14:44:42  InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
190822 14:44:42  InnoDB: Waiting for the background threads to start
190822 14:44:43 InnoDB: 5.5.59 started; log sequence number 1940403
190822 14:44:43 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
190822 14:44:43 [Note]   - '0.0.0.0' resolves to '0.0.0.0';
190822 14:44:43 [Note] Server socket created on IP: '0.0.0.0'.
190822 14:44:43 [ERROR] /usr/libexec/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 2)
190822 14:44:43 [ERROR] Can't start server: can't create PID file: No such file or directory

問題找到了:不能創建PID文件:沒有這樣的文件或目錄

於是去查看,果然沒有文件夾

[root@djaljdw ~]#  cd /var/run [root@djaljdw ~]#  mkdir mysqld [root@djaljdw ~]#  cd mysqld [root@djaljdw ~]#  touch mysqld.pid 重啟服務還是報錯 於是又查看日誌
190822 14:56:51 [Note] Plugin 'FEDERATED' is disabled.
190822 14:56:51 InnoDB: The InnoDB memory heap is disabled
190822 14:56:51 InnoDB: Mutexes and rw_locks use GCC atomic builtins
190822 14:56:51 InnoDB: Compressed tables use zlib 1.2.3
190822 14:56:51 InnoDB: Using Linux native AIO
190822 14:56:51 InnoDB: Initializing buffer pool, size = 128.0M
190822 14:56:51 InnoDB: Completed initialization of buffer pool
190822 14:56:51 InnoDB: highest supported file format is Barracuda.
InnoDB: The log sequence number in ibdata files does not match
InnoDB: the log sequence number in the ib_logfiles!
190822 14:56:51  InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
190822 14:56:51  InnoDB: Waiting for the background threads to start
190822 14:56:52 InnoDB: 5.5.59 started; log sequence number 1940403
190822 14:56:52 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
190822 14:56:52 [Note]   - '0.0.0.0' resolves to '0.0.0.0';
190822 14:56:52 [Note] Server socket created on IP: '0.0.0.0'.
190822 14:56:52 [ERROR] /usr/libexec/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 13)
190822 14:56:52 [ERROR] Can't start server: can't create PID file: Permission denied

發現:無法創建PID文件:許可權被拒絕

解決辦法: 修改 /var/run/mysqld/許可權為mysql  [root@djaljdw ~]#  chown -R mysql /var/run/mysqld [root@djaljdw ~]#  chgrp -R mysql /var/run/mysqld [root@djaljdw ~]#  chmod 777 /var/run/mysqld

重啟服務完美解決

tip:看日誌是解決問題的一個很好的辦法!

 


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • MySql學習筆記1 1.SQL 分類 1. DDL(Data Definition Language)數據定義語言 2. DML(Data Manipulation Language)數據操作語言 3. DQL(Data Query Language)數據查詢語言 4. DCL(Data Cont ...
  • SQL概要與表的創建 1.表的結構 ​ 關係資料庫通過類似Excel 工作表那樣的、由行和列組成的二維表來管理數據。用來管理數據的二維表在關係資料庫中簡稱為表。 ​ 根據 SQL 語句的內容返回的數據同樣必須是二維表的形式 ,這也是關係資料庫的特征之一 。返回結果如果不是二維表的SQL 語句則無法執 ...
  • 語法:DELETE FROM 表名 WHERE id NOT IN ( SELECT temp.min_id FROM ( SELECT MIN(id) min_id FROM 表名 GROUP BY 欄位名 )AS temp ); 備註:id:也是表欄位 實例:DELETE FROM pro_co ...
  • 參考資料:https://stackoverflow.com/questions/22008859/the-name-is-not-a-valid-identifier-error-in-function 執行存儲過程中sql字元串: ...
  • 我們都知道 sql語句中的排序有desc(降序)、asc(升序),這兩個都是按順序排列的,最近有一個需求是不按順序排序了 ,抽出個別的排在前面,並且這種需求是應對的問題中的數據是比較少的,而且沒有規律可循,用程式處理的話雖然能實現,但是處理起來會複雜很多,下麵我們就通過對order by 後面的排序 ...
  • ​ 此文選自Google大神Tyler Akidau的另一篇文章:Streaming 102: The world beyond batch ​ 歡迎回來!如果您錯過了我以前的帖子, "Streaming 大數據的未來" ,強烈建議您先花時間閱讀那篇文章。 簡要回顧一下,上一篇我們介紹了Stream ...
  • 一張表就是一本新華字典。聚集索引就是頁碼,在這個頁碼上有真正的數據,並且字典就是按照頁碼從小到達來印刷和裝訂的。非聚集索引就是按照拼音檢索,按照部首檢索,按照筆畫數檢索,可以理解成3個非聚集索引。這些非聚集索引上會有一個頁號,但是真正的內容需要你翻開那一頁才能看到。包含性的非聚集索引就是在普通的非聚 ...
  • 一個sysadmin離職了,但是因為之前是他配置的Always-on,所以試圖Drop他的login就會失敗,原因是這個login會賦予一個叫做“Hadr_endpoint”的endpoint許可權,並且是這個endpoint的owner。 如果直接嘗試revoke,會提示錯誤,無法revoke。 也 ...
一周排行
    -Advertisement-
    Play Games
  • 1. 說明 /* Performs operations on System.String instances that contain file or directory path information. These operations are performed in a cross-pla ...
  • 視頻地址:【WebApi+Vue3從0到1搭建《許可權管理系統》系列視頻:搭建JWT系統鑒權-嗶哩嗶哩】 https://b23.tv/R6cOcDO qq群:801913255 一、在appsettings.json中設置鑒權屬性 /*jwt鑒權*/ "JwtSetting": { "Issuer" ...
  • 引言 集成測試可在包含應用支持基礎結構(如資料庫、文件系統和網路)的級別上確保應用組件功能正常。 ASP.NET Core 通過將單元測試框架與測試 Web 主機和記憶體中測試伺服器結合使用來支持集成測試。 簡介 集成測試與單元測試相比,能夠在更廣泛的級別上評估應用的組件,確認多個組件一起工作以生成預 ...
  • 在.NET Emit編程中,我們探討了運算操作指令的重要性和應用。這些指令包括各種數學運算、位操作和比較操作,能夠在動態生成的代碼中實現對數據的處理和操作。通過這些指令,開發人員可以靈活地進行算術運算、邏輯運算和比較操作,從而實現各種複雜的演算法和邏輯......本篇之後,將進入第七部分:實戰項目 ...
  • 前言 多表頭表格是一個常見的業務需求,然而WPF中卻沒有預設實現這個功能,得益於WPF強大的控制項模板設計,我們可以通過修改控制項模板的方式自己實現它。 一、需求分析 下圖為一個典型的統計表格,統計1-12月的數據。 此時我們有一個需求,需要將月份按季度劃分,以便能夠直觀地看到季度統計數據,以下為該需求 ...
  • 如何將 ASP.NET Core MVC 項目的視圖分離到另一個項目 在當下這個年代 SPA 已是主流,人們早已忘記了 MVC 以及 Razor 的故事。但是在某些場景下 SSR 還是有意想不到效果。比如某些靜態頁面,比如追求首屏載入速度的時候。最近在項目中回歸傳統效果還是不錯。 有的時候我們希望將 ...
  • System.AggregateException: 發生一個或多個錯誤。 > Microsoft.WebTools.Shared.Exceptions.WebToolsException: 生成失敗。檢查輸出視窗瞭解更多詳細信息。 內部異常堆棧跟蹤的結尾 > (內部異常 #0) Microsoft ...
  • 引言 在上一章節我們實戰了在Asp.Net Core中的項目實戰,這一章節講解一下如何測試Asp.Net Core的中間件。 TestServer 還記得我們在集成測試中提供的TestServer嗎? TestServer 是由 Microsoft.AspNetCore.TestHost 包提供的。 ...
  • 在發現結果為真的WHEN子句時,CASE表達式的真假值判斷會終止,剩餘的WHEN子句會被忽略: CASE WHEN col_1 IN ('a', 'b') THEN '第一' WHEN col_1 IN ('a') THEN '第二' ELSE '其他' END 註意: 統一各分支返回的數據類型. ...
  • 在C#編程世界中,語法的精妙之處往往體現在那些看似微小卻極具影響力的符號與結構之中。其中,“_ =” 這一組合突然出現還真不知道什麼意思。本文將深入剖析“_ =” 的含義、工作原理及其在實際編程中的廣泛應用,揭示其作為C#語法奇兵的重要角色。 一、下劃線 _:神秘的棄元符號 下劃線 _ 在C#中並非 ...