项目场景:
Mysql 启动报错: mysqld: [ERROR] Found option without preceding group in config file /etc/my.cnf at line 1!
# 启动mysql
systemctl start mysqld
问题描述:
# 查看启动日志
journalctl
-xe
Sep 03 15:10:09 cluster-node-1 mysqld_pre_systemd[17180]: my_print_defaults: [ERROR] Found option without preceding group in config file /etc/my.cnf
Sep 03 15:10:09 cluster-node-1 mysqld_pre_systemd[17180]: my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
Sep 03 15:10:09 cluster-node-1 mysqld_pre_systemd[17180]: my_print_defaults: [ERROR] Found option without preceding group in config file /etc/my.cnf
Sep 03 15:10:09 cluster-node-1 mysqld_pre_systemd[17180]: my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
Sep 03 15:10:09 cluster-node-1 mysqld[17198]: mysqld: [ERROR] Found option without preceding group in config file /etc/my.cnf at line 1!
Sep 03 15:10:09 cluster-node-1 mysqld[17198]: mysqld: [ERROR] Fatal error in defaults handling. Program aborted!
Sep 03 15:10:09 cluster-node-1 systemd[1]: mysqld.service: control process exited, code=exited status=1
Sep 03 15:10:09 cluster-node-1 systemd[1]: Failed to start MySQL Server.
原因分析:
mysql配置文件编码格式有误!
Mysql配置文件:/etc/my.cnf
在使用win下编辑器配置 my.cnf 时,导致文件编码格式改变。
解决方案:
使用编辑器打开 my
.cnf
点击 编码(N)
选择 使用 UTF
-8 编码
ctrl
+ s 保存即可
# 重启mysql
systemctl restart mysqld
# 查看mysql状态
systemctl status mysqld