Mysql启动失败

Mysql启动失败

我正在运行 Ubuntu 12.04 LTS 虚拟机。上周,虚拟机意外停止,现在 mysql 无法在虚拟机上启动。这两个事件可能相关,也可能不相关。

当我尝试连接时:

$ mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

然后:

$ sudo service mysql start
start: Job failed to start

$ dmesg

[ 1838.218400] type=1400 audit(1374633238.253:50): apparmor="STATUS" operation="profile_replace" name="/usr/sbin/mysqld" pid=18473 comm="apparmor_parser"
[ 1838.358656] init: mysql main process (18477) terminated with status 1
[ 1838.358695] init: mysql main process ended, respawning
[ 1839.269303] init: mysql post-start process (18478) terminated with status 1

$ service mysql status
mysql stop/waiting

我认为这意味着 mysql 在启动时崩溃了:

$ sudo mysqld start
130723 21:51:24  InnoDB: Assertion failure in thread 3064211200 in file fut0lst.ic line 83
InnoDB: Failing assertion: addr.page == FIL_NULL || addr.boffset >= FIL_PAGE_DATA
InnoDB: We intentionally generate a memory trap.
InnoDB: Submit a detailed bug report to http://bugs.mysql.com.
InnoDB: If you get repeated assertion failures or crashes, even
InnoDB: immediately after the mysqld startup, there may be
InnoDB: corruption in the InnoDB tablespace. Please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.5/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.
02:51:24 UTC - mysqld got signal 6 ;

根据手册之后,我进入数据目录 (/var/lib/mysql) 并运行以下命令:

myisamchk --silent --force */*.MYI

然后:

$ sudo mysqld
...
InnoDB: Your database may be corrupt or you may have copied the InnoDB
InnoDB: tablespace but not the InnoDB log files. See
InnoDB: http://dev.mysql.com/doc/refman/5.5/en/forcing-innodb-recovery.html
InnoDB: for more information.
...

我的数据库损坏了吗?我该怎么做才能恢复?重新安装 mysql?还是用其他更简单的方法?丢失数据库没关系,我只想要一个可以正常工作的系统。

答案1

重新创建 mysqld.sock 文件可能会起作用。

 cd /var/run/mysqld
 sudo touch mysqld.sock
 sudo chown mysql:mysql mysqld.sock
 sudo chmod 1777 mysqld.sock
 sudo service mysql restart

如果没有,请执行以下操作并发布结果:

 cd /var/run/mysqld
 ls -al

答案2

有时可以通过以安全模式启动来解决损坏的 MySQL 安装问题。

重要的在安全模式下运行 MySQL 会降低安全设置,可能允许其他人访问您的数据。

要以安全模式启动,请运行:

sudo /usr/bin/mysqld_safe --user=mysql --skip-grant-tables

如果您发现您的表格确实已损坏,可以采取几个步骤来修复它们。这里有一个很好的教程链接。 http://tech.amikelive.com/node-36/mysql-50-recovering-crashedcorrupted-innodb-database/

http://www.mysqlperformanceblog.com/2008/07/04/recovering-innodb-table-corruption/

答案3

检查 my.cnf,查找文件夹tmp位置。然后检查该位置的权限是否为777。因为文件夹的默认权限是755,所以tmp它应该是777

错误 2002 (HY000):无法通过套接字“/var/run/mysqld/mysqld.sock”连接到本地 MySQL 服务器 (2)

相关内容