try to change bin log directory: mysql-bin.index n

2020-05-14 08:38发布

MySQL 5.1.54 Ubuntu 11.04

I'am try to change bin log directory in my.conf as:

[mysqld]
log_bin=/home/developer/logs/mysql/mysql-bin.log

After this changes MySQL server can't start with error:

/usr/sbin/mysqld: File '/home/developer/logs/mysql/mysql-bin.index' 
not found (Errcode: 13)
111005 12:47:58 [ERROR] Aborting

Permission for directory /home/developer/logs/mysql/ is 0777

What's going on?

13条回答
孤傲高冷的网名
2楼-- · 2020-05-14 09:10

Option 1:

  1. service mysqld stop

  2. Copy the log files including the .index file to new location.

     cp mysql-bin.log* /path/to/binlogs
     cp mysql-bin.index /path/to/binlogs
    
  3. Do Changes in the /etc/my.cnf file.

    [mysqld]
    log-bin=/path/to/newdirecory/mysql-bin
    
    log-bin-index=/path/to/newdirectory/mysql-bin.index
    
  4. service mysqld start

Option 2:

Use this utiltiy to relocate binary logs:

mysqlbinlogmove --binlog-dir=/server/data /new/binlog_dir
查看更多
聊天终结者
3楼-- · 2020-05-14 09:11

As documentation in mysql say https://dev.mysql.com/doc/refman/5.7/en/replication-options-binary-log.html#sysvar_log_bin

The variable is log_bin and not log-bin at least in version 5.7

查看更多
Melony?
4楼-- · 2020-05-14 09:14

Your config is wrong:

log_bin=/home/developer/logs/mysql/mysql-bin.log

You would use instead

log-bin=/home/developer/logs/mysql/mysql-bin.log
查看更多
趁早两清
5楼-- · 2020-05-14 09:15

/usr/sbin/mysqld: File '/usr/binlogs/mysql-bin.index' not found (Errcode: 13)

It worked for me with:

chown -R mysql:mysql /usr/binlogs/

查看更多
ゆ 、 Hurt°
6楼-- · 2020-05-14 09:17

As usual, the solution was simple but not obvious: it needed to edit apparmor settings I just added to /etc/apparmor.d/usr.sbin.mysqld a new string with path to target directory: /home/developer/logs/* rw

It works!

查看更多
家丑人穷心不美
7楼-- · 2020-05-14 09:18

Just as an FYI for anyone who runs into a similar problem, the solution is basically the same, but the cause of the problem isn't obvious.

After upgrading Debian wheezy, mysql failed to start.

Somehow, I have no idea how, permissions on some of the files in /var/lib/mysql were not owned by the mysql user, thus preventing the server from firing up.

A chown -R mysql.mysql /var/lib/mysql fixed it.

I didn't do anything to mess up mysql, it was a standard:

apt-get update

apt-get upgrade

Something got hinky during the Debian upgrade and manual intervention was needed.

查看更多
登录 后发表回答