title: InnoDB: Operating system error number 13 in a file operation not fixed after changing permissions in /var/lib/mysql/ or disabling selinux
body: <p>When I run <code>mysql</code>, I get the error of <code>ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)</code>. <code>mysqld</code> gives the error of</p>
  <pre><code>    150101 12:08:19 [Warning] Can't create test file /var/lib/mysql/lamp-update.lower-test
      150101 12:08:19 [Warning] Can't create test file /var/lib/mysql/lamp-update.lower-test
      150101 12:08:19 [Warning] One can only use the --user switch if running as root
  
      150101 12:08:19 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
      150101 12:08:19 [Note] Plugin 'FEDERATED' is disabled.
      mysqld: Can't find file: './mysql/plugin.frm' (errno: 13)
      150101 12:08:19 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
      150101 12:08:19 InnoDB: The InnoDB memory heap is disabled
      150101 12:08:19 InnoDB: Mutexes and rw_locks use GCC atomic builtins
      150101 12:08:19 InnoDB: Compressed tables use zlib 1.2.8
      150101 12:08:19 InnoDB: Using Linux native AIO
      150101 12:08:19 InnoDB: Initializing buffer pool, size = 128.0M
      150101 12:08:19 InnoDB: Completed initialization of buffer pool
      150101 12:08:19  InnoDB: Operating system error number 13 in a file operation.
      InnoDB: The error means mysqld does not have the access rights to
      InnoDB: the directory.
      InnoDB: File name ./ibdata1
      InnoDB: File operation call: 'open'.
      InnoDB: Cannot continue operation.
  </code></pre>
  <p><code>sudo mysqld</code> gives the output of <code>150101 12:11:59 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.</code></p>
  <p>I am running a virtual ubuntu linux server. Mysql has worked without a problem until yesterday, when I got this error.</p>
  <p>I have tried to set the permissions of the files in /var/lib/mysql to 660, /var/lib/mysql to 755, and its subdirectories to 700. I then ran <code>sudo chown -R mysql:mysql /var/lib/mysql</code>. Then, I tried rebooting my server, and running mysqld. I got the same error.</p>
  <p>Then, I tried disabling selinux by running <code>sudo vim /etc/selinux/semanage.conf</code> and adding <code>SELINUX=disabled</code> to the file as the first line. I rebooted again, and got the same error.</p>
  <p>This is the extent of any advice I have seen on stackexchange or other sites.</p>
  <p>Does anyone have any ideas for what I could do?</p>
  <p>Thank you,</p>
  <p>Daniel</p>
  <h1>Edit:</h1>
  <p>I &quot;solved&quot; my problem by running mysqld as root, but this doesn't seem like a good idea security wise, so I am still looking for a better solution.</p>