Mysql won't start - ibdata1 corrupt? - operati

2020-02-02 10:43发布

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.

14条回答
爱情/是我丢掉的垃圾
2楼-- · 2020-02-02 11:33

I had the same problem and fix by below steps

Working directory /var/lib/mysql

Earlier /var/lib/mysql was owned by some unknown user

Changed it to mysql

mysql]# chown -R mysql:mysql *

mysql]# service mariadb start

Redirecting to /bin/systemctl start mariadb.service

Works like a charm

查看更多
Viruses.
3楼-- · 2020-02-02 11:34

please check this:

chown -R mysql:mysql /var/lib/mysql
查看更多
Anthone
4楼-- · 2020-02-02 11:37

I had exactly the same problem on my CentOS box. After moving mysql data directory around I couldn't start the service anymore, even as I had copied the files with the same owner and permissions.

I had a problem with the SELinux security context. If you run your CentOS stock it has good chance to be enabled and won't let do what you want with MySQL. To fix this :

First compare the old dir and new dir using

ls -Z /var/lib/mysql 

and

ls -Z /new/mysql/dir

If you see any difference it's likely to be your problem. To modify this :

chcon -R --type=mysql_db_t /new/mysql/dir

The -R switch is for recursion. If you only need to change one file you can omit it.

查看更多
疯言疯语
5楼-- · 2020-02-02 11:42

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 ~]#
查看更多
时光不老,我们不散
6楼-- · 2020-02-02 11:42

For me, restoring the security context (selinux) did the trick

restorecon -R /var/lib/mysql/

查看更多
Rolldiameter
7楼-- · 2020-02-02 11:42

I had exactly the same problem on my CentOS box. After moving mysql data directory around I couldn't start the service anymore, even as I had copied the files with the same owner and permissions.

I had a problem with the SELinux security context. If you run your CentOS stock it has good chance to be enabled and won't let do what you want with MySQL. To fix this :

First compare the old dir and new dir using

ls -Z /var/lib/mysql 

and

ls -Z /new/mysql/dir

If you see any difference it's likely to be your problem. To modify this :

chcon -R --type=mysql_db_t /new/mysql/dir

The -R switch is for recursion. If you only need to change one file you can omit it. If your context is different than mine(maybe a different distro), use the one indicated by the output of the first (it should be the 3rd field of the SELinux stuff)

ls -Z /var/lib/mysql 
查看更多
登录 后发表回答