Linux – OS error number 13 in file operations on CentOS?

OS error number 13 in file operations on CentOS?… here is a solution to the problem.

OS error number 13 in file operations on CentOS?

I’m trying to change the data directory on mysql. However, the following error occurs:

121213 04:40:28 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
121213 04:41:00 mysqld_safe Starting mysqld daemon with databases from /home/mysql_data
121213  4:41:00 [Warning] Can't create test file /home/mysql_data/localhost.lower-test
121213  4:41:00 [Warning] Can't create test file /home/mysql_data/localhost.lower-test
121213  4:41:00  InnoDB: Initializing buffer pool, size = 8.0M
121213  4:41:00  InnoDB: Completed initialization of buffer pool
121213  4:41:00  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.

I’ve seen on a lot of websites that this is a permissions issue. So please tell me how to do that because I don’t know much about Linux.

Thank you.

Solution

Errno 13 == permission denied.

You can see the full list in /usr/include/sys/errno.h1.

In your place, I’ll use one

sudo mysqld -s /bin/bash

What starts the shell with the name of the mysql server. Then I would try to change mysql’s directory (/var/lib/mysql) and if I can’t create/delete something there, that’s the cause of the problem. Maybe you can use some chown/chmod commands (as root) to fix this.

For example, chown mysql: mysql

-rc/var/lib/mysql generates all files, recursively to the ownership of the user (and group) “mysql”, showing you the changes

12019 update: Today on Linux is /usr/include/asm-generic/errno-base.h.

Related Problems and Solutions