33

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?

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
solo117
  • 1,069
  • 2
  • 11
  • 12

13 Answers13

38

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!

solo117
  • 1,069
  • 2
  • 11
  • 12
27

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

It worked for me with:

chown -R mysql:mysql /usr/binlogs/

Mzf
  • 5,210
  • 2
  • 24
  • 37
Pradeep Jadhav
  • 279
  • 3
  • 2
14

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.

atw
  • 5,428
  • 10
  • 39
  • 63
Halfstop
  • 1,710
  • 17
  • 34
3

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.

Jim Ockers
  • 31
  • 1
3

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
Matt
  • 74,352
  • 26
  • 153
  • 180
Jeeva
  • 89
  • 1
  • 3
2

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

chown -R mysql:mysql /home/developer/logs/mysql/
Sujit Devkar
  • 1,195
  • 3
  • 12
  • 22
1

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/

Vaisakh PS
  • 1,181
  • 2
  • 10
  • 19
1

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.

Andreas
  • 2,211
  • 1
  • 18
  • 36
  • i have copied permissions from /var/log/mysql directory. No results. – solo117 Oct 05 '11 at 12:26
  • and what happens if you su to the mysqld user and try to access the directory? – Andreas Oct 05 '11 at 12:28
  • i run "sudo -u mysql touch /home/developer/logs/test.txt", it succesfully created a file – solo117 Oct 05 '11 at 12:33
  • 2
    I believe in this case the error message and the error code are misleading ... When I hit this, I've even tried to create a new index file with the list of binary logs ..., this didn't work either. – Dimitre Radoulov Oct 05 '11 at 13:27
0

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
0

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

Samrendra
  • 117
  • 1
  • 2
0

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.

Swaps
  • 1,450
  • 24
  • 31
0

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

0

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 ...

Dimitre Radoulov
  • 27,252
  • 4
  • 40
  • 48
  • What do you mean? stop server -> disable log_bin ->start server ->...stop server->enable log_bin -> start server_ ??? unfortunately it's not worked for me – solo117 Oct 05 '11 at 12:46
  • Not exactly. Do you also change the datadir position? If yes, this is what I did in order to make it work: disable log-bin in the configuration file, mysql_install_db with the customized configuration file, at the end of the installation mysqld is started by the install script. After that: stop, enable log-bin, start. – Dimitre Radoulov Oct 05 '11 at 13:01
  • It should be noted that this was during a new setup. If you have an existing database, your situation is different. – Dimitre Radoulov Oct 05 '11 at 13:07