出現問題的可能性
1、可能是/opt/mysql/data/數據目錄mysql用戶沒有權限(修改數據目錄的權限)
解決方法 :給予權限,執行 "chown -R mysql.mysql /opt/mysql/data" 然后重新啟動mysqld
2、可能進程里已經存在mysql進程
解決方法:用命令“ps -ef|grep mysqld”查看是否有mysqld進程,如果有使用“kill -9 進程號”殺死,然后重新啟動mysqld!
3、可能是第二次在機器上安裝mysql,有殘余數據影響了服務的啟動。
解決方法:去mysql的二進制日志目錄看看,如果存在mysql-binlog.index,就趕快把它刪除掉吧
4、mysql在啟動時沒有指定配置文件時會使用/etc/my.cnf配置文件,請打開這個文件查看在[mysqld]下有沒有指定數據目錄(datadir)。
解決方法:請在[mysqld]下設置這一行:datadir = /opt/mysql/data
5、skip-federated字段問題
解決方法:檢查一下/etc/my.cnf文件中有沒有沒被注釋掉的skip-federated字段,如果有就立即注釋掉吧。
6、錯誤日志目錄不存在
解決方法:使用“chown” “chmod”命令賦予mysql所有者及權限
7、selinux惹的禍,如果是centos系統,默認會開啟selinux
|
1
2
|
解決方法:先臨時改為警告模式:[root@www php]
# setenforce 0
然后打開
/etc/sysconfig/selinux
,把SELINUX=enforcing改為SELINUX=disabled
|
8、啟動失敗注意檢查數據目錄的權限,要與mysql程序運行用戶權限一致。
|
1
|
[root@db01 mysql]
# chown -R mysql.mysql ../mysql
|
最好是整個mysql程序目錄都授權予mysql用戶。
附加:
經驗之談:
還有一個原因可能是:
查看配置文件/usr/local/mysql/my.cnf里有沒有innodb_buffer_pool_size這個參數
innodb_buffer_pool_size:主要作用是緩存innodb表的索引,數據,插入數據時的緩沖;
默認值:128M;
專用mysql服務器設置此值的大小: 系統內存的70%-80%最佳。
如果你的系統內存不大,查看這個參數,把它的值設置小一點吧
總結:
在配置文件/etc/my.cnf添加錯誤日志參數,一切問題都解決
|
1
2
|
[mysqld_safe]
log-error =
/data/mysql/logs/error
.log
|
啟動報錯時查看日志信息:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#tail -f /data/mysql/logs/error.log
160721 06:12:07 mysqld_safe Starting mysqld daemon with databases from
/data/mysql/data
2016-07-21 06:12:10 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation
for
more
details).
2016-07-21 06:12:10 0 [Note]
/opt/mysql/bin/mysqld
(mysqld 5.6.27-log) starting as process 2290 ...
2016-07-21 06:12:10 2290 [Note] Plugin
'FEDERATED'
is disabled.
2016-07-21 06:12:10 2290 [Warning] The option innodb (skip-innodb) is deprecated and will be removed
in
a future release
2016-07-21 06:12:10 2290 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-07-21 06:12:10 2290 [Note] InnoDB: The InnoDB memory heap is disabled
2016-07-21 06:12:10 2290 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-07-21 06:12:10 2290 [Note] InnoDB: Memory barrier is not used
2016-07-21 06:12:10 2290 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-07-21 06:12:10 2290 [Note] InnoDB: Using CPU crc32 instructions
2016-07-21 06:12:10 2290 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-07-21 06:12:10 2290 [Note] InnoDB: Completed initialization of buffer pool
2016-07-21 06:12:10 2290 [Note] InnoDB: Highest supported
file
format
is Barracuda.
2016-07-21 06:12:11 2290 [Note] InnoDB: 128 rollback segment(s) are active.
2016-07-21 06:12:11 2290 [Note] InnoDB: Waiting
for
purge to start
2016-07-21 06:12:11 2290 [Note] InnoDB: 5.6.27 started; log sequence number 1625997
2016-07-21 06:12:11 2290 [ERROR]
/opt/mysql/bin/mysqld
: unknown option
'--slave_parallel_workers=3'
2016-07-21 06:12:11 2290 [ERROR] Aborting
2016-07-21 06:12:11 2290 [Note] Binlog end
2016-07-21 06:12:11 2290 [Note] Shutting down plugin
'partition'
2016-07-21 06:12:11 2290 [Note] Shutting down plugin
'INNODB_SYS_DATAFILES'
2016-07-21 06:12:11 2290 [Note] Shutting down plugin
'INNODB_SYS_TABLESPACES'
2016-07-21 06:12:11 2290 [Note] Shutting down plugin
'INNODB_SYS_FOREIGN_COLS'
2016-07-21 06:12:11 2290 [Note] Shutting down plugin
'INNODB_SYS_FOREIGN'
2016-07-21 06:12:11 2290 [Note] Shutting down plugin
'INNODB_SYS_FIELDS'
|
發現日志輸出
|
1
2
|
2016-07-21 06:12:11 2290 [ERROR]
/opt/mysql/bin/mysqld
: unknown option
'--slave_parallel_workers=3'
2016-07-21 06:12:11 2290 [ERROR] Aborting
|
肯定是配置文件里加入了這個錯誤參數,去掉即可
新加報錯:
Starting MySQL.171019 10:11:54 mysqld_safe error: log-error set to '/data/tools/mysql/logs/error.log', however file don't exists. Create writable for user 'mysql'.
這是在mysql新版本:5.6.35,5.6.36的一個bug
參考:https://bugs.mysql.com/bug.php?id=84427
解決:
手動創建日志文件:
|
1
2
3
4
5
|
touch
/data/tools/mysql/logs/error
.log
chown
mysql.
/data/tools/mysql/logs/error
.log
/etc/init
.d
/mysqld
start
|
轉自http://732233048.blog.51cto.com/9323668/1636409,版權歸作者所有。
