mysql不能开启二进制日志,我修改my.cnf以后mysql就不能启动了

Web、Mail、Ftp、DNS、Proxy、VPN、Samba、LDAP 等基础网络服务
回复
gtiubvrd
帖子: 62
注册时间: 2011-07-29 19:16

mysql不能开启二进制日志,我修改my.cnf以后mysql就不能启动了

#1

帖子 gtiubvrd » 2016-10-02 15:22

我在/etc/mysql/my.cnf文件里加入以下内容:
[mysqld]
local-infile=0
log-bin=~/mysql_logbin
然后重启mysql:
sudo /etc/init.d/mysql restart
结果重启失败。其他日志也是不能开启,例如log、log-slow-queries。
poloshiao
论坛版主
帖子: 18279
注册时间: 2009-08-04 16:33

Re: mysql不能开启二进制日志,我修改my.cnf以后mysql就不能启动了

#2

帖子 poloshiao » 2016-10-02 20:09

重启mysql:
sudo /etc/init.d/mysql restart
结果重启失败。
1. 如果是 Ubuntu 16.04 請使用
sudo systemctl restart mysql.service
1-1. 參見
https://help.ubuntu.com/16.04/servergui ... figuration
其他日志也是不能开启,例如log、log-slow-queries。
2. 請舉實際例子及回應訊息 記得 提供 Ubuntu 版本
头像
vickycq
帖子: 4507
注册时间: 2011-03-20 13:12
系统: Debian
来自: 山东省寿光县
联系:

Re: mysql不能开启二进制日志,我修改my.cnf以后mysql就不能启动了

#3

帖子 vickycq » 2016-10-02 20:16

gtiubvrd 写了:log-bin=~/mysql_logbin
尝试不要使用 ~,使用完整路径
其次保证相关进程有权限读写日志文件。假设相关进程以用户 "mysql" 身份运行,设置日志文件的属主/属组使用户 "mysql" 有权限读写日志文件。
Debian 中文论坛 - forums.debiancn.org
欢迎所有 Debian GNU/Linux 用户
gtiubvrd
帖子: 62
注册时间: 2011-07-29 19:16

Re: mysql不能开启二进制日志,我修改my.cnf以后mysql就不能启动了

#4

帖子 gtiubvrd » 2016-10-04 12:24

问题还没解决,我详细说明:
OS: UBUNTU 16.04 LTS,我在/etc/mysql/my.cnf文件里加入以下内容:
[mysqld]
local-infile=0
log-bin=/home/bob/mysql_logbin

然后执行:
cd ~
touch mysql_logbin
sudo chown mysql:mysql mysql_logbin
ls -al mysql_logbin
输出:
-rw-rw-r-- 1 mysql mysql 0 10月 4 11:54 mysql_logbin
sudo systemctl restart mysql.service
输出:Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
sudo systemctl status mysql.service > 1.txt
vim 1.txt
内容:
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: activating (start-post) (Result: exit-code) since 二 2016-10-04 12:03:23 CST; 30s ago
Process: 27230 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
Process: 27225 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 27230 (code=exited, status=1/FAILURE); : 27231 (mysql-systemd-s)
CGroup: /system.slice/mysql.service
└─control
├─27231 /bin/bash /usr/share/mysql/mysql-systemd-start post
└─27283 sleep 1

10月 04 12:03:23 bob-computer systemd[1]: Starting MySQL Community Server...
10月 04 12:03:27 bob-computer mysqld[27230]: 2016-10-04T04:03:25.204981Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
10月 04 12:03:27 bob-computer mysqld[27230]: 2016-10-04T04:03:25.211443Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)
10月 04 12:03:27 bob-computer mysqld[27230]: 2016-10-04T04:03:27.348271Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
10月 04 12:03:27 bob-computer mysqld[27230]: 2016-10-04T04:03:27.457090Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.15-0ubuntu0.16.04.1-log) starting as process 27230 ...
10月 04 12:03:27 bob-computer mysqld[27230]: 2016-10-04T04:03:27.477555Z 0 [ERROR] You have enabled the binary log, but you haven't provided the mandatory server-id. Please refer to the proper server start-up parameters documentation
10月 04 12:03:27 bob-computer mysqld[27230]: 2016-10-04T04:03:27.484983Z 0 [ERROR] Aborting
10月 04 12:03:27 bob-computer mysqld[27230]: 2016-10-04T04:03:27.485163Z 0 [Note] Binlog end
10月 04 12:03:27 bob-computer mysqld[27230]: 2016-10-04T04:03:27.487184Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
10月 04 12:03:27 bob-computer systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE

我发现以上这条是重要的,所以我在/etc/mysql/my.cnf文件里加入一条server-id:
[mysqld]
local-infile=0
log-bin=/home/bob/mysql_logbin
server-id=1
然后
sudo systemctl restart mysql.service > 1.txt
vim 1.txt
输出
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: activating (start-post) (Result: exit-code) since 二 2016-10-04 12:14:58 CST; 14s ago
Process: 28825 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
Process: 28820 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 28825 (code=exited, status=1/FAILURE); : 28826 (mysql-systemd-s)
CGroup: /system.slice/mysql.service
└─control
├─28826 /bin/bash /usr/share/mysql/mysql-systemd-start post
└─28859 sleep 1

10月 04 12:14:58 bob-computer systemd[1]: Starting MySQL Community Server...
10月 04 12:15:00 bob-computer systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE

搞了半天还是启动不了,只要my.cnf文件什么都不配置就能正常启动mysql。开启log-bin还有什么步骤要注意?
回复