Fail to stop mysql (Unable to lock ./ibdata1, error: 11)


Staff member
Since two days, I can't connect to mysql with my root account.
I have no problem to log in with the other accounts.

I first thought my server was hacked and that somebody changed the password. I tried to reset it. To do so, I had to use mysqld_safe and therefore to stop mysql, that I failed to do:

> sudo /etc/init.d/mysql stop
Stopping MySQL database server: mysqld failed!

> mysqld stop
InnoDB: Unable to lock ./ibdata1, error: 11
InnoDB: Check that you do not already have another mysqld process
InnoDB: using the same InnoDB data or log files.
130107 13:48:34  InnoDB: Unable to open the first data file
InnoDB: Error in opening ./ibdata1
130107 13:48:34  InnoDB: Operating system error number 11 in a file operation.
InnoDB: Error number 11 means 'Resource temporarily unavailable'.
InnoDB: Some operating system error numbers are described at
InnoDB: Could not open or create data files.
InnoDB: If you tried to add new data files, and it failed here,
InnoDB: you should now edit innodb_data_file_path in my.cnf back
InnoDB: to what it was, and remove the new ibdata files InnoDB created
InnoDB: in this failed attempt. InnoDB only wrote those files full of
InnoDB: zeros, but did not yet use them in any way. But be careful: do not
InnoDB: remove old data files which contain your precious data!
130107 13:48:34 [ERROR] Plugin 'InnoDB' init function returned error.
130107 13:48:34 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
mysqld: Too many arguments (first extra is 'stop').

MySQL couldn't read ibdata1, so I check its permissions that looks correct:

> ls -l /var/lib/mysql/
-rw-rw---- 1 mysql mysql 18874368 Jan  7 12:39 ibdata1
-rw-rw---- 1 mysql mysql  5242880 Jan  7 13:05 ib_logfile0
-rw-rw---- 1 mysql mysql  5242880 Jan  7 13:05 ib_logfile1

I tried to move and copy the file like <a href="" rel="noreferrer">explained here</a>, without any success:

&gt; mv /var/lib/mysql/ibdata1 /var/lib/mysql/ibdata1.bak
&gt; cp -a /var/lib/mysql/ibdata1.bak /var/lib/mysql/ibdata1

Here is a part of my.cnf

user            = mysql
pid-file        = /var/run/mysqld/
socket          = /var/run/mysqld/mysqld.sock
port            = 3306
basedir         = /usr
datadir         = /var/lib/mysql
tmpdir          = /tmp
LANGUAGE        = /usr/share/mysql/english

The datadir is correct.

As well, here is what happens when I try to get MySQL status:

# sudo /etc/init.d/mysql status
/usr/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'debian-sys-maint'@'localhost' (using password: YES)'

I found a solution to this problem on <a href="" rel="noreferrer">this page</a>, but I have to log in as a root user to do so, that I can't do. I guess the two problems are linked.

Does anyone of you knows how to fix this? I'm blocked in my work because of this.

Thank you a lot for reading this message and maybe to reply to it.

Have a nice day!