当前位置:   article > 正文

ubuntu下mysql服务重启失败解决思路_mysql.service: failed with result 'exit-code'.

mysql.service: failed with result 'exit-code'.

今天,在遇到ERROR 1290 (HY000): running with the –secure-file-priv错误,根据网上提示(参考),在配置文件my.cnf添加
通过命令 find / -name my.cnf 或者locate my.cnf查找配置文件所在位置。

secure_file_priv='/var/lib/mysql-files/'
  • 1

接着重启mysql服务,出现提示:

root@vultr:~/weixin/wx# /etc/init.d/mysql restart
[....] Restarting mysql (via systemctl): mysql.serviceJob for mysql.service failed because the control process exited with error code.
See "systemctl  status mysql.service" and "journalctl  -xe" for details.
  • 1
  • 2
  • 3
  • 4

按照上面提示通过systemctl status mysql.service”或者 “journalctl -xe”查看

root@vultr:~/weixin/wx# systemctl  status mysql.service
● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: activating (start-post) (Result: exit-code) since Sat 2018-06-23 06:25:25 UTC;
  Process: 19444 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
  Process: 19428 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, stat
 Main PID: 19444 (code=exited, status=1/FAILURE); Control PID: 19445 (mysql-systemd-s)
    Tasks: 2 (limit: 4915)
   Memory: 484.0K
      CPU: 82ms
   CGroup: /system.slice/mysql.service
           └─control
             ├─19445 /bin/bash /usr/share/mysql/mysql-systemd-start post
             └─19481 sleep 1

Jun 23 06:25:25 vultr.guest systemd[1]: mysql.service: Service hold-off time over, schedu
Jun 23 06:25:25 vultr.guest systemd[1]: Stopped MySQL Community Server.
Jun 23 06:25:25 vultr.guest systemd[1]: Starting MySQL Community Server...
Jun 23 06:25:25 vultr.guest mysql-systemd-start[19428]: my_print_defaults: [ERROR] Found 
Jun 23 06:25:25 vultr.guest mysql-systemd-start[19428]: my_print_defaults: [ERROR] Fatal 
Jun 23 06:25:25 vultr.guest mysqld[19444]: mysqld: [ERROR] Found option without preceding
Jun 23 06:25:25 vultr.guest mysqld[19444]: mysqld: [ERROR] Fatal error in defaults handli
Jun 23 06:25:25 vultr.guest systemd[1]: mysql.service: Main process exited, code=exited, 
lines 1-22/22 (END)

root@vultr:~/weixin/wx# journalctl -xe
-- Unit mysql.service has failed.
-- 
-- The result is failed.
Jun 23 06:25:55 vultr.guest systemd[1]: mysql.service: Unit entered failed state.
Jun 23 06:25:55 vultr.guest systemd[1]: mysql.service: Failed with result 'exit-code'.
Jun 23 06:25:56 vultr.guest systemd[1]: mysql.service: Service hold-off time over, schedu
Jun 23 06:25:56 vultr.guest systemd[1]: Stopped MySQL Community Server.
-- Subject: Unit mysql.service has finished shutting down
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- Unit mysql.service has finished shutting down.
Jun 23 06:25:56 vultr.guest systemd[1]: Starting MySQL Community Server...
-- Subject: Unit mysql.service has begun start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- Unit mysql.service has begun starting up.
Jun 23 06:25:56 vultr.guest mysql-systemd-start[19524]: my_print_defaults: [ERROR] Found 
Jun 23 06:25:56 vultr.guest mysql-systemd-start[19524]: my_print_defaults: [ERROR] Fatal 
Jun 23 06:25:56 vultr.guest smbd[19512]: pam_unix(samba:session): session closed for user
Jun 23 06:25:56 vultr.guest mysqld[19540]: mysqld: [ERROR] Found option without preceding
Jun 23 06:25:56 vultr.guest mysqld[19540]: mysqld: [ERROR] Fatal error in defaults handli
Jun 23 06:25:56 vultr.guest systemd[1]: mysql.service: Main process exited, code=exited,
  • 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
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51

这些错误提示看得让我一脸懵逼,我能怎么办?看几遍也没啥收获,ok,往深一步想想系统自带的log日志会不会有这写错误,查看mysql目录,tail -10 /var/log/mysql/error.log,什么输出也没有。。。那其它日志是否有记录这个错误,往上一层看,看到syslog,突然想起些什么。(原来syslog日志记录了很多详细信息,其中有进程id和正文)

root@vultr:~/weixin/wx# cat /var/log/syslog
Jun 23 06:25:25 vultr systemd[1]: Failed to start MySQL Community Server.
Jun 23 06:25:25 vultr systemd[1]: mysql.service: Unit entered failed state.
Jun 23 06:25:25 vultr systemd[1]: mysql.service: Failed with result 'exit-code'.
Jun 23 06:25:25 vultr systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Jun 23 06:25:25 vultr systemd[1]: Stopped MySQL Community Server.
Jun 23 06:25:25 vultr systemd[1]: Starting MySQL Community Server...
Jun 23 06:25:25 vultr mysql-systemd-start[19428]: my_print_defaults: [ERROR] Found option without preceding group in config file /etc/mysql/my.cnf at line 22!
Jun 23 06:25:25 vultr mysql-systemd-start[19428]: my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
Jun 23 06:25:25 vultr mysqld[19444]: mysqld: [ERROR] Found option without preceding group in config file /etc/mysql/my.cnf at line 22!
Jun 23 06:25:25 vultr mysqld[19444]: mysqld: [ERROR] Fatal error in defaults handling. Program aborted!
Jun 23 06:25:25 vultr systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

看到上面有一句说22行,把这一句翻译过来大概的意思就是:“my.cnf添加了22行信息,并没有在前面找到[mysql]选项”。最后在配置文件开头加上[mysqld],重新启动成功。

总结:
有时候通过特定提示看到的错误提示并没有解决,当然英语好也许一眼看出systemctl status mysql.service或者 journalctl -xe上面的提示。当然方法我相信还是有的,万能的系统自带日志,看着一类日志,往往更容易查到错误提示。

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

闽ICP备14008679号