Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

InnoDB: Operating system error number 13 in a file operation not fixed after changing permissions in /var/lib/mysql/ or disabling selinux

When I run mysql, I get the error of ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2). mysqld gives the error of

    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.

sudo mysqld gives the output of 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.

I am running a virtual ubuntu linux server. Mysql has worked without a problem until yesterday, when I got this error.

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 sudo chown -R mysql:mysql /var/lib/mysql. Then, I tried rebooting my server, and running mysqld. I got the same error.

Then, I tried disabling selinux by running sudo vim /etc/selinux/semanage.conf and adding SELINUX=disabled to the file as the first line. I rebooted again, and got the same error.

This is the extent of any advice I have seen on stackexchange or other sites.

Does anyone have any ideas for what I could do?

Thank you,

Daniel

Edit:

I "solved" 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.

like image 772
Daniel F Avatar asked Jan 01 '15 18:01

Daniel F


2 Answers

In my case SELinux was enabled and by disabling SELinux i was able to start the service

To disable SELlinux, edit

/etc/sysconfig/selinux

and set

SELINUX=disabled

Reboot and verify with command

sestatus

Folder permissions in my case are

chown -R mysql:mysql /mnt/efs/fs1/mysql

chmod -R 750 /mnt/efs/fs1/mysql

where /mnt/efs/fs1/mysql is my data directory

like image 189
Monish Sen Avatar answered Oct 25 '22 19:10

Monish Sen


I could solve this by changing the ownership of the folder to mysql from group root (sudo chown -R mysql:root folder). Once I did this, all started to work again.

Regards

like image 25
Leandro Avatar answered Oct 25 '22 18:10

Leandro