7

两天以来,我无法使用我的 root 帐户连接到 mysql。我用其他帐户登录没有问题。

我首先以为我的服务器被黑了,有人更改了密码。我试图重置它。为此,我不得不使用 mysqld_safe 并因此停止 mysql,但我没有这样做:

> 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: http://dev.mysql.com/doc/refman/5.1/...ror-codes.html
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 无法读取 ibdata1,所以我检查了它看起来正确的权限:

> 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

我尝试按照此处的说明移动和复制文件,但没有成功:

> mv /var/lib/mysql/ibdata1 /var/lib/mysql/ibdata1.bak
> cp -a /var/lib/mysql/ibdata1.bak /var/lib/mysql/ibdata1

这是 my.cnf 的一部分

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

数据目录是正确的。

同样,当我尝试获取 MySQL 状态时会发生以下情况:

# 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)'

我在此页面上找到了解决此问题的方法,但是我必须以 root 用户身份登录才能这样做,这是我做不到的。我想这两个问题是联系在一起的。

你们中有人知道如何解决这个问题吗?因为这个,我的工作受阻。

非常感谢您阅读此消息并可能回复它。

祝你今天过得愉快!

4

0 回答 0