Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysql won't start - ibdata1 corrupt? - operating system error number 13 - permissions issue

Server shutdown from power failure.
Mysql will not start now.
Disk is not full. Syslog is below

Oct 11 15:03:31 joe mysqld_safe[24757]: started Oct 11 15:03:31 joe mysqld[24760]: 101011 15:03:31  InnoDB: Operating system error number 13 in a file operation. Oct 11 15:03:31 joe mysqld[24760]: InnoDB: The error means mysqld does not have the access rights to Oct 11 15:03:31 joe mysqld[24760]: InnoDB: the directory. Oct 11 15:03:31 joe mysqld[24760]: InnoDB: File name ./ibdata1 Oct 11 15:03:31 joe mysqld[24760]: InnoDB: File operation call: 'create'. Oct 11 15:03:31 joe mysqld[24760]: InnoDB: Cannot continue operation. 
like image 908
eat_a_lemon Avatar asked Oct 11 '10 15:10

eat_a_lemon


People also ask

What is ibdata1 in MySQL?

The file ibdata1 is the system tablespace for the InnoDB infrastructure. It contains several classes for information vital for InnoDB. Table Data Pages. Table Index Pages. Data Dictionary.

How do I shrink the purge ibdata1 file in MySQL?

The ibdata1 file cannot shrink, it is a particularly troublesome feature of MySQL. The ibdata1 file can be shrinked if you delete all databases, remove the files and reload the mysqldump. We can configure MySQL so that each table, including its indexes, is stored as a separate file.

What causes MySQL server to fail to start?

Errors in configuration – MySQL stores its configuration settings in ‘/etc/my.cnf’ file. Any errors or unsupported parameters in this config file can prevent the server from starting. Corrupt MySQL binary – When MySQL binary or tables gets corrupt, it can cause the MySQL server to fail or not start.

Why can’t I run MySQL on my port?

MySQL port already in use – If some other process is running in the MySQL port (default 3306), MySQL would be unable to bind to the port and cannot run. Unable to write to /tmp – If the /tmp directory is not writable due to permission issues or lack of space, MYSQL cannot write the needed files and cannot start.

Why is my InnoDB file not working?

InnoDB has corruption detection (page checksums) and would happily tell you if that were the problem. Either the directory permissions have changed, or your my.cnf file has been hosed, and it's trying to recreate data files somewhere else.

Why does MySQL keep crashing on startup?

Out of memory – If MySQL process is not getting enough memory due to abusive processes or any other valid process, it cannot start or would keep crashing all the time. [ You don’t have to lose your sleep to keep your customers happy. Our friendly Support Engineers are online 24/7/365 to help your customers.


2 Answers

If you are using ubuntu or apparmor you should permit this change in apparmor.

Edit /etc/apparmor.d/usr.sbin.mysqld and change /var/lib/mysql with the new DATADIR.

It should work.

like image 120
Dan Avatar answered Sep 21 '22 05:09

Dan


Error:

 101130 14:42:51 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended 101130 18:07:58 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 101130 18:07:58  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. 

Solution SeLinux SeLinux security:

 [root@localhost ~]# service mysqld restart Deteniendo mysqld:                                         [  OK  ] Iniciando mysqld:                                          [  FALLÓ  ] [root@localhost ~]#  restorecon -R /var/lib/mysql/ [root@localhost ~]# service mysqld restart Deteniendo mysqld:                                         [  OK  ] Iniciando mysqld:                                          [  OK  ] [root@localhost ~]# 
like image 38
Carlos Omar Briseño Gutierrez Avatar answered Sep 21 '22 05:09

Carlos Omar Briseño Gutierrez