CentOS上,用命令:service mysqld restart 啟動mysql報錯:
# service mysqld restart
Stopping mysqld: [ OK ]
MySQL Daemon failed to start.
Starting mysqld: [FAILED]
進入mysql相關目錄查看:
# cd /var/lib/mysql/ # ls hhw_global ibdata1 ib_logfile0 ib_logfile1 localhost.localdomain.err mysql mysql.sock test
查看服務器啟動日志:
# tail localhost.localdomain.err 190610 20:16:57 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 190610 20:16:57 [ERROR] You need to use --log-bin to make --binlog-format work. 190610 20:16:57 [ERROR] Aborting 190610 20:16:57 [Note] /usr/libexec/mysqld: Shutdown complete 190610 20:16:57 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
可用看到,兩行報錯說的是,開了--binlog-format選項卻沒有開啟bin log,因此mysql進程開不起來。使用如下命令,查看一下配置的位置:
# mysqld --verbose --help|grep -A 1 'Default options'
或者是:
# mysql --verbose --help|grep -A 1 'Default options'
查詢結果:
# mysql --verbose --help|grep -A 1 'Default options' Default options are read from the following files in the given order: /etc/mysql/my.cnf /etc/my.cnf ~/.my.cnf
找到相應的my.cnf,修改相應配置項,重啟mysqld服務即可。