1. 程式人生 > >mysql5.6啟動失敗的一般解決方法

mysql5.6啟動失敗的一般解決方法

本文針對mysql5.6而言:
     
   MySQL server PID file could not be found!
   Starting MySQL...The server quit without updating PID file (/var/lib/mysql/mysql.pid).
----------------------------------------------------------------
      關於該問題的解決方法,這裡總結得不錯:
http://www.oicqzone.com/pc/2015012120844.html
----------------------------------------------------------------
         只是關於第六點:

               6.錯誤日誌目錄不存在
                解決方法:使用“chown” “chmod”命令賦予mysql所有者及許可權
       其實日誌檔案不存在或者許可權不夠,mysql能夠啟動,只是預設不開啟該日誌記錄功能了。如下記錄:
/usr/local/mysql/bin/mysqld: File '/var/log/mysqllog/query.log' not found (Errcode: 13 - Permission denied)
2017-01-20 11:11:28 14629 [ERROR] Could not open /var/log/mysqllog/query.log for logging (error 13). Turning logging off for the whole duration of the MySQL server process. To turn it on again: fix the cause, shutdown the MySQL server and restart it.


另外,還有這種說法,效果未知,沒有驗證

                    “在網上查了很多資料,都不是我這種情況,後來終於有高手幫忙說是,刪除/usr/local/mysql/data/下的2個檔案。ib_logfile0和ib_logfile1”
有一點還需要注意一下,就是5.6版本的配置檔案的配置項,有很大改變,例如,開啟慢查詢日誌的選型:
         5.6之前是:log-slow-queries=/var/log/mysqllog/query_slow.log
 5.6則為:      slow_query_log = on 
     slow-query-log-file = /var/log/mysqllog/slow-query.log
     long_query_time = 1   (秒)
      這些都是需要注意的,否則還是啟動不了。
   總結,其實只要根據日誌來確定無法啟動失敗的原因,一般都是可以解決的。



附上我的配置:

[mysqld]
#default-character-set = utf8
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M


# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
log-bin=mysql-bin
binlog_format=mixed


# These are commonly set, remove the # and set as required.
basedir = /usr/local/mysql
datadir = /var/lib/mysql
port = 3306
# server_id = .....
socket = /tmp/mysql.sock
user=mysql
character_set_server=utf8
init_connect='SET NAMES utf8'


log-error=/var/log/mysqllog/query_err.log


general_log=ON
general_log_file=/var/log/mysqllog/query.log
pid-file = /var/lib/mysql/mysql.pid
#慢查詢日誌,add by cyc
slow_query_log = on
slow-query-log-file = /var/log/mysqllog/slow-query.log
long_query_time = 1
[safe_mysqld]
err-log = /var/log/mysqld.log
#pid-file = /var/lib/mysql/mysql.pid


# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M 


sql_mode=NO_ENGINE_SUBSTITUTION