ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ 的解决

系统:CentOS

因为数据迁移到另一台机器,发现MySQL起不来,报错:

ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)

想删除mysql.sock,结果没有

[root@host ~]# rm /var/lib/mysql/mysql.sock
rm: cannot lstat `/var/lib/mysql/mysql.sock’: No such file or directory

重启服务失败

[root@host ~]# service mysqld start
Timeout error occurred trying to start MySQL Daemon.
Starting MySQL:                                            [FAILED]

强行从控制台起

结果报错:

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.
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.

提示已经mysqld进程存在,但是这个使用重启服务是可以启动mysql的.结果几个小时候还是挂了.

突然想到InnoDB引擎驱动mysql的话在磁盘转移之后会有问题,之前甘总做李宁funrun专题时候就遇到过.

根据提示,我想弄成相同的日志文件,可是咋弄啊.然后想了一下,好吧,停止服务,删掉ib_logfile0和ib_logfile1,重启.
嘿,几天了没挂.

One Response to ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ 的解决

  1. 代码方面不是很懂啊

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>