title: mysqld: File '/var/log/mysql/mysql-bin.index' not found (Errcode: 13)
body: <p>I faced with this error after trying to restart MySQL server. </p>
  
  <pre><code>root@private:/# mysqld_safe 
  140618 03:56:53 mysqld_safe Can't log to error log and syslog at the same time.  Remove all --log-error configuration options for --syslog to take effect.
  140618 03:56:53 mysqld_safe Logging to '/var/log/mysql/error.log'.
  140618 03:56:53 mysqld_safe Starting mysqld daemon with databases from /mysql
  140618 03:56:53 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
  </code></pre>
  
  <p>The approach I've followed (and most found on internet) that is <strong>changing permission of /var/log/mysql to mysql user</strong>. <strong><em>But it doesn't work</em></strong>.</p>
  
  <pre><code>drwxr-s---  2 mysql             mysql       4096 Jun 18 03:31 mysql/
  </code></pre>
  
  <p>Inside:</p>
  
  <pre><code>root@private:/var/log# ll mysql
  total 12
  drwxr-s---  2 mysql mysql 4096 Jun 18 03:31 ./
  drwxr-xr-x 24 root  root  4096 Jun 18 03:27 ../
  -rw-r-----  1 mysql mysql 1989 Jun 18 03:34 error.log
  -rwxrwxrwx  1 mysql mysql    0 Jun 18 03:13 mysql-bin.index*
  </code></pre>
  
  <p>My data path:</p>
  
  <pre><code>drwxr-xr-x   3 mysql    mysql     4096 Jun 18 03:27 mysql/
  </code></pre>
  
  <p>I even tried to re-install MySQL as well but the error doesn't disappear. </p>
  
  <p>Please help me!!!</p>
  
  <p><strong>Update 1:</strong> About my.cnf - error-log configuration. I turned on both general and error log (to error.log). But nothing inside the general log file. For the error log file, there is no thing more than the error I copied above.</p>
  
  <pre><code># Both location gets rotated by the cronjob.
  # Be aware that this log type is a performance killer.
  # As of 5.1 you can enable the log at runtime!
  general_log_file        = /var/log/mysql/mysql.log
  general_log             = 1
  #
  # Error log - should be very few entries.
  #
  log_error = /var/log/mysql/error.log
  #
  # Here you can see queries with especially long duration
  #log_slow_queries       = /var/log/mysql/mysql-slow.log
  #long_query_time = 2
  #log-queries-not-using-indexes
  </code></pre>
  
  <p><strong>Update 2:</strong> regarding the question of apparmor or selinux, I just use apparmor. I also tried to append: </p>
  
  <pre><code>/var/log/* rw
  </code></pre>
  
  <p>to</p>
  
  <pre><code>/etc/apparmor.d/usr.sbin.mysqld
  </code></pre>
  
  <p>but it either doesn't work</p>
  
  <p><strong><em>Update 3:</em></strong></p>
  
  <p>And I believe following changes did work for my case:</p>
  
  <ul>
  <li><p>Have to be sure that mysql account has enough permission (rw) to your mysql log/data directories. From root or sudoer account just try to switch to mysql user then create/edit any test file.</p></li>
  <li><p>Don't remove or disable apparmor and update mysql profile (normally usr.sbin.mysqld) with following thing:</p>
  
  <p>/var/log/mysql-bin.index rw,</p>
  
  <p>/mysql/* rw,</p></li>
  </ul>
  
  <p>you might customize them according to your case.</p>
  
  <ul>
  <li><p>reload mysql profile</p>
  
  <p>apparmor_parser -r /etc/apparmor.d/usr.sbin.mysqld</p></li>
  </ul>
  
  <p>and restart it.</p>
  
  <p>Hope it will hep for any one who came across internet and paid hours for changing permission  and apparmor without any lucky.</p>