当前位置:   article > 正文

Brew 安装MySQL后,将配置文件my.cnf 添加到/etc/my.cnf后启动服务报错(The server quit without updating PID file……)_brew mysql my.cnf

brew mysql my.cnf

 brew install mysql后并没有进行my.cnf配置,所有新建了个my.cnf文件将以前的配置项都添加到了这个配置文件中,然后重启MySQL服务,结果就报错了

. ERROR! The server quit without updating PID file (/usr/local/var/mysql/bogon.pid).

网上找了资料,并没有解决我的问题,后面只能是逐一排查

这是我的配置文件(/etc/my.cnf)简单的内容

  1. # For advice on how to change settings please see
  2. # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
  3. # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
  4. # *** default location during install, and will be replaced if you
  5. # *** upgrade to a newer version of MySQL.
  6. [client]
  7. default-character-set=utf8mb4
  8. [mysql]
  9. default-character-set=utf8mb4
  10. [mysqld]
  11. character-set-client-handshake = FALSE
  12. character-set-server = utf8mb4
  13. collation-server = utf8mb4_unicode_ci
  14. init_connect='SET NAMES utf8mb4'
  15. lower_case_table_names=1
  16. # Remove leading # and set to the amount of RAM for the most important data
  17. # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
  18. # innodb_buffer_pool_size = 128M
  19. # Remove leading # to turn on a very important data integrity option: logging
  20. # changes to the binary log between backups.
  21. # log_bin
  22. # These are commonly set, remove the # and set as required.
  23. # basedir = .....
  24. # datadir = .....
  25. # port = .....
  26. # server_id = .....
  27. # socket = .....
  28. # Remove leading # to set options mainly useful for reporting servers.
  29. # The server defaults are faster for transactions and fast SELECTs.
  30. # Adjust sizes as needed, experiment to find the optimal values.
  31. # join_buffer_size = 128M
  32. # sort_buffer_size = 2M
  33. # read_rnd_buffer_size = 2M
  34. sql_mode = "STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER"

启动MySQL服务

  1. $ mysql.server start
  2. Starting MySQL
  3. .. ERROR! The server quit without updating PID file (/usr/local/var/mysql/bogon.pid).

就发现包这个错误,尝试了各种办法授权目录,等等没结果,后面只能是逐一排查my.cnf文件里面的配置,结果真的是这个配置文件里面的问题,我一行一行的注释后再启动,终于在注释以下两个配置项后,终于不报这个错误了。

  1. # lower_case_table_names=1
  2. # sql_mode = "STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER"
  3. 或者将sql_mode中的NO_AUTO_CREATE_USER去掉也可以

然后启动错误不报但又有以下的提示信息 

  1. $ mysql.server start
  2. Starting MySQL
  3. SUCCESS!
  4. bogon:~ liwu$ 2019-06-19T08:17:38.6NZ mysqld_safe A mysqld process already exists

出现这种提示的时候可以使用Brew service来操作MySQL服务,先停止MySQL服务

  1. $ brew services stop mysql
  2. Stopping `mysql`... (might take a while)
  3. ==> Successfully stopped `mysql` (label: homebrew.mxcl.mysql)
  4. bogon:~ liwu$ mysql.server start
  5. Starting MySQL
  6. . SUCCESS!

至此此问题终于得到了一个解答

总结:

我觉得出现这种现象有几种种可能

1、我的MySQL不是在官网下载对应兼容版本的*.dmg安装包

2、我是采用的HomeBrew方式安装的,没有原始安装包那么齐全

3、有可能是MySQL版本的问题,我现在的版本是MySQL-8.0.16,但这个怀疑还得得到验证

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/529636
推荐阅读
相关标签
  

闽ICP备14008679号