Starting MySQL...The server quit without updating PID file [失敗]lib/mysql/localhost.localdomain.pid).,localhost

來源:互聯網
上載者:User

Starting MySQL...The server quit without updating PID file [失敗]lib/mysql/localhost.localdomain.pid).,localhost

重啟了一下伺服器,啟動後就報以下錯誤了:

Starting MySQL...The server quit without updating PID file [失敗]lib/mysql/localhost.localdomain.pid).

糾結了很久沒找到解決辦法,後來突然想到修改了mysql的設定檔“/usr/my.cnf”

之前配置預設編碼,在設定檔中添加了“default-character-set=utf8


把這一句刪除了,再啟動mysql就好了。


在解決這個問題過程中找到的比較好的資料,這裡收藏一下:

問題起因:
今天做了一件事情:我在VM 上將一資料庫的資料檔案(/var/lib/mysql整個檔案夾)拷貝到另外一台VM上,然後新的VM 上啟動MYSQL,結果報如下異常:
[root@localhost mysql]# service mysql start
Starting MySQL.. ERROR! The server quit without updating PID file (/var/lib/mysql/localhost.localdomain.pid).
於是Google之,大部分的答案都是:
1. 注釋/etc/my.cnf裡的skip-federated注釋掉即#skip-federated;
2. my.cnf檔案配置過高,重新定義其中的參數(根據伺服器情況定義);
3. 殺掉mysql_safe和mysqld進程,然後再重啟;
4. 當前記錄檔過大,超出了my.cnf中定義的大小(預設為64M),刪除記錄檔再重啟;

5. 其他情況,查看記錄檔(我的是localhost.localdomain.err,具體因人而異),然後具體分析;


問題解決:

其中,我查看了日誌內容,如下:

[root@localhost mysql]# less localhost.localdomain.err 
111203 22:09:03 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
^G/usr/sbin/mysqld: File './mysql-bin.index' not found (Errcode: 13)
111203 22:09:03 [ERROR] Aborting

111203 22:09:03 [Note] /usr/sbin/mysqld: Shutdown complete

111203 22:09:03 mysqld_safe mysqld from pid file /var/lib/mysql/localhost.localdomain.pid ended


但是我查看了我的目錄檔案,mysql-bin.index檔案是存在的呀,奇怪:

[root@localhost mysql]# ll
total 49828
-rw-rw----. 1 mysql mysql 35651584 Dec  3 17:55 ibdata1
-rw-rw----. 1 mysql mysql  5242880 Dec  3 17:55 ib_logfile0
-rw-rw----. 1 mysql mysql  5242880 Dec  3 15:45 ib_logfile1
-rw-rw----. 1 mysql root      1376 Dec  3 22:02 localhost.localdomain.err
drwx--x--x. 2 mysql mysql     4096 Dec  3 17:55 mysql
-rw-rw----. 1 mysql mysql  4847020 Dec  3 17:55 mysql-bin.000001
-rw-rw----. 1 mysql mysql     1373 Dec  3 17:56 mysql-bin.000002
-rw-r--r--. 1 root  root        19 Dec  3 15:38 mysql-bin.index
drwx------. 2 mysql mysql     4096 Dec  3 17:55 performance_schema
-rw-r--r--. 1 root  root       116 Nov 25 21:03 RPM_UPGRADE_HISTORY
-rw-r--r--. 1 mysql mysql      116 Nov 25 21:03 RPM_UPGRADE_MARKER-LAST
drwxr-xr-x. 2 mysql mysql     4096 Dec  3 17:55 test

仔細看了下,咦?-rw-r--r--. 1 root  root        19 Dec  3 15:38 mysql-bin.index----難道是許可權不夠?於是將該檔案加了寫入權限,重啟,濤聲依舊!!!噢噢!


難道是編碼問題?難道是....繼續猜測。。。問題還是沒解決,後來我做了一件事情,將mysql-bin.index檔案刪除掉!重啟!!OH!No!!

[root@localhost mysql]# rm -rf mysql-bin.index 
[root@localhost mysql]#  
[root@localhost mysql]# service mysql start
Starting MySQL... SUCCESS! 


就這樣??為什麼呢?至今這個仍然是未解之謎(對我來說),如有知情者請告知:)


補充:

很多時候,我們在做主從同步的時候,將資料庫目錄整體打包拷貝到從機上的時候,重啟也往往會出現類似的問題,解決方案仍然是:

1)給MYSQL資料庫資料目錄許可權:chown -R mysql:mysql 目錄名稱

2)務必保證MYSQL的進程是已經關閉了的;


另外要注意的地方就是:ib_*, mysql-bin-*, *.err(log檔案)以及master-info和relay-info檔案都是可以刪除的,相當於重新初始化資料庫的資料,但是前提是:

1)操作前要先關掉MYSQL的進程;

2)刪掉檔案後要重新啟動MYSQL,如果有異常,請自行查看日誌找問題,一般都比較好定位和解決。



Starting MySQLThe server quit without updating PID file (/var/lib/mysql/localhostlocaldomainpid

問題描述: [root@bogon mysql-5.1.41]# /etc/rc.d/init.d/mysqld startStarting MySQL.Manager of pid-file quit without updating file.[失敗] --------------------------- 解決辦法:配置的時候有一個步驟是 cp support-files/my-medium.cnf /etc/my.cnf ; 就編輯my.cnf,在[mysqld]下面加上:datadir = /usr/local/mysql/data 例如# The MySQL server[mysqld]port = 3306socket = /tmp/mysql.sockskip-lockingkey_buffer_size = 16Mmax_allowed_packet = 1Mtable_open_cache = 64sort_buffer_size = 512Knet_buffer_length = 8Kread_buffer_s ...

2.首先到/usr/local/mysql/data先 chown -R mysql:mysql * 然後殺掉mysql進程,在啟動musql就行了

開啟/etc/selinux/config,把SELINUX=enforcing改為SELINUX=disabled後存檔退出重啟機器試試3.

4.確實一般都是my.cnf設定檔的問題
/etc/my.cnf來自以下檔案:

如果你的記憶體≤64M,則複製/usr/local/share/mysql/my-small.cnf為/etc/my.cnf
# This is for a system with little memory (<= 64M) where MySQL is only used
# from time to time and it's important that the mysqld daemon
# doesn't use much resources.

如果記憶體是128M,則複製/usr/local/share/mysql/my-medium.cnf為/etc/my.cnf
# This is for a system with little memory (32M - 64M) where MySQL plays
# an important part, or systems up to 128M where MySQL is used together with
# other programs (such as a web server)

如果記憶體是512M,則複製/usr/local/share/mysql/my-large.cnf為/etc/my.cnf
# This is for a large system with memory = 512M where the system runs mainly
# MyS......餘下全文>>
 
linux啟動mysql錯誤: The server quit without updating PID file (lib/mysql/solr4pid)

意思是你這個服務退出但是他的pid沒有更新,也就是進程沒有關掉的意識,用命令找到那個進程,然後Kill it!!!
————————————————
請採納!!!
 

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.