MySQL資料庫啟動失敗解決

來源:互聯網
上載者:User

MySQL資料庫啟動失敗解決

重啟伺服器後-->重啟應用服務(Confluence)-->報錯,資料庫連接失敗(MySQL設定了開機自啟動)-->查看MySQL資料庫狀態:

[root@ www.bkjia.com ~]# ps -ef | grep mysql
root    25555 21974  0 11:28 pts/0    00:00:00 grep mysql

啟動mysql伺服器

[root@ www.bkjia.com data]# service mysql start
MySQL server PID file could not be found![失敗]
Starting MySQL.............. ERROR! The server quit without updating PID file (/mydata/data/fisheye..pid).[失敗]

查看錯誤記錄檔:

[root@ www.bkjia.com data]# tail -100 fisheye.err
InnoDB: Last MySQL binlog file position 0 337403929, file name ./mysql-bin.000016
141013  1:13:28  InnoDB: Waiting for the background threads to start
141013  1:13:29 InnoDB: 5.5.33 started; log sequence number 1006647152
17:13:29 UTC - mysqld got signal 11 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help
di141013 01:13:29 mysqld_safe mysqld from pid file /mydata/data/fisheye.pid ended

未發現明顯性錯誤提示,所以手動建立一個pid檔案試試

[root@ www.bkjia.com data]# touch /mydata/data/fisheye.pi

再進行重啟服務:

[root@ www.bkjia.com data]# service mysql restart
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

突然想到之前看過此類報錯的文章,記得有可能是磁碟空間不足導致的mysql無法啟動。

[root@ www.bkjia.com data]# df -h
檔案系統              容量  已用 可用 已用% 掛載點
/dev/sda1            9.5G  9.5G  0  100% /
/dev/sda4            5.5G  1.3G  4.0G  24% /mnt/backup
/dev/mapper/IhuilianVG-IhuilianLV00
                      22G  4.2G  17G  20% /var/www/app
tmpfs                1.3G    0  1.3G  0% /dev/shm

果然如此,下面羅列一些類似問題(無法啟動)的解決思路:

1.可能是datadir目錄存在的分區滿了(df -h )

      解決方案:開啟設定檔/etc/my.cnf,在[mysqld]節下重新指定資料目錄(datadir),並將原來的資料目錄遷移到重新制定的資料目錄處

      關於遷移:(1)、cp或者tar的時候一定要把許可權給帶上,但是為防止意外建議再授權一次;(2)、資料比較大時一定要先壓縮再遷移,保證完整性,特別是scp到其他機器時可能會逾時所以一定要壓縮(tar.gz);(3)、若是移動至另外的伺服器一定要保證mysql版本一致。

2.可能是/mydata/data/fisheye.pid檔案沒有寫的許可權

      解決方案 :給予許可權,執行 “chown -R mysql:mysql /mydata/data/”  然後重新啟動mysqld!

3.可能進程裡已經存在mysql進程

      解決方案:用命令“ps -ef|grep mysqld”查看是否有mysqld進程,如果有使用“kill -9  進程號”殺死,然後重新啟動mysqld!

4.可能是第二次在機器上安裝mysql,有殘餘資料影響了服務的啟動。

      解決方案:去mysql的資料目錄/data看看,如果存在mysql-bin.index,就趕快把它刪除掉吧,它就是罪魁禍首了。

5.skip-federated欄位問題(報錯資訊:[ERROR] /mydata/data/mysql/libexec/mysqld: unknown option '--skip-federated')

      解決方案:檢查一下/etc/my.cnf檔案中有沒有沒被注釋掉的skip-federated欄位,如果有就立即注釋掉吧。

6.selinux惹的禍,如果是CentOS系統,預設會開啟selinux

      解決方案:關閉它,開啟/etc/selinux/config,把SELINUX=enforcing改為SELINUX=disabled後存檔退出重啟機器試試。

Linux下MySQL啟動失敗的解決一例

--------------------------------------分割線 --------------------------------------

Ubuntu 14.04下安裝MySQL

《MySQL權威指南(原書第2版)》清晰中文掃描版 PDF

Ubuntu 14.04 LTS 安裝 LNMP Nginx\PHP5 (PHP-FPM)\MySQL

Ubuntu 14.04下搭建MySQL主從伺服器

Ubuntu 12.04 LTS 構建高可用分布式 MySQL 叢集

Ubuntu 12.04下原始碼安裝MySQL5.6以及Python-MySQLdb

MySQL-5.5.38通用二進位安裝

--------------------------------------分割線 --------------------------------------

本文永久更新連結地址:

相關文章

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.