try to change bin log directory: mysql-bin.index not found (Errcode: 13)

≯℡__Kan透↙ 提交于 2019-12-03 02:42:48

问题


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?


回答1:


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!




回答2:


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

It worked for me with:

chown -R mysql:mysql /usr/binlogs/




回答3:


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.




回答4:


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



回答5:


Selinux might enforce the rule that MySQL database files have to live in /var/lib/mysql and not anywhere else. Try turning off selinux (selinux=0 on kernel boot command line) if you moved mysql to another directory.




回答6:


You need to give user permissions to the directory as follows:

chown -R mysql:mysql /home/developer/logs/mysql/



回答7:


mysqld: File '/data/log/mysql/mysql-bin.index' not found (Errcode: 2 - No such file or directory)

I was really stuck in the middle of my MySQL Master - Slave setup. Finally the above was a permission issue, adding the below command solved my issue.

chown -R mysql:mysql /data/log/mysql/




回答8:


Does your user have access to all upper directories? In special, the /home/developer/ directory? Try to log in with the mysql server account and touch the log file.




回答9:


I had a similar problem when I was trying to change the datadir variable during a fresh install. The solution in my case was to run the first time start up with log-bin disabled. After that I was able to enable it again using the new path ...




回答10:


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



回答11:


During replication configuration in "my.cnf" file needs to mention

server-id=1 log_bin=/var/log/mysql/mysql-bin.log

you can make your own directory and give permission. create directory "mysql" in /var/log/

chmod 777 mysql

this is applicable with MySQL version 5.7




回答12:


You can also comment the line in my.cnf file which is defining the log location, so mysql will consider its default path and will start properly.

log-bin = /var/log/mysql/mysql-bin.log -> #log-bin = /var/log/mysql/mysql-bin.log.

This will be helpful if you are not concerned much about logs.




回答13:


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



来源:https://stackoverflow.com/questions/7660410/try-to-change-bin-log-directory-mysql-bin-index-not-found-errcode-13

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!