On CentOS, start MySQL with the command: Service mysqld restart
# service mysqld restart
Stopping mysqld: [ OK ]
MySQL Daemon failed to start.
Starting mysqld: [FAILED]
Enter the MySQL related directory to view:
# cd /var/lib/mysql/
# ls
hhw_global ibdata1 ib_logfile0 ib_logfile1 localhost.localdomain.err mysql mysql.sock test
To view the server startup log:
# 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
As you can see, the two lines reported an error saying that the — binlog format option was turned on, but bin log was not turned on, so the MySQL process could not be started. Use the following command to view the location of the configuration:
# mysqld --verbose --help|grep -A 1 'Default options'
Or:
# mysql --verbose --help|grep -A 1 'Default options'
Query results:
# 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
Find the corresponding my.cnf, modify the corresponding configuration item, and restart mysqld service