服务器宕机后 mysql 数据库出现问题求解

2016-06-20 11:05:54 +08:00
 Tony1ee

今天早些时候经历了宕机,服务器恢复以后,网站就挂了。
访问 tony1ee.com 提示建立数据库连接时出错。
ssh 连接服务器,启动 mysql 遇到了问题
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
登入phpmyadmin也登入不上
应该是Mysql出的问题 当时是一键安装的 lnmp 现在求助大伙这是个什么情况,怎么解决?

3951 次点击
所在节点    问与答
19 条回复
Livid
2016-06-20 11:07:58 +08:00
看 MySQL 的出错日志,里面会有具体的错误信息。
McContax
2016-06-20 11:10:13 +08:00
打个赌,内存被 php-fpm 占满, Mysql 内存不足挂掉
Tony1ee
2016-06-20 11:11:09 +08:00
@McContax 内存空的很
9hills
2016-06-20 11:14:56 +08:00
打个赌, MySQL 数据文件损坏无法启动
Tony1ee
2016-06-20 11:17:26 +08:00
@Livid
@9hills
@McContax
mysql 无法启动 提示 ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
izoabr
2016-06-20 11:17:52 +08:00
手工启动一下数据库,然后看下日志
lijinma
2016-06-20 11:18:38 +08:00
明显你连数据库服务器都没启动吧。。。你看看进程?
jugelizi
2016-06-20 11:18:52 +08:00
删除那个文件
之前也在 linux 下遇到过
p2p
2016-06-20 11:25:11 +08:00
重启动下 mysql 就完了
Tony1ee
2016-06-20 11:30:40 +08:00
@Livid
@izoabr
错误日志:
160620 08:59:13 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/var
160620 8:59:13 InnoDB: The InnoDB memory heap is disabled
160620 8:59:13 InnoDB: Mutexes and rw_locks use GCC atomic builtins
160620 8:59:13 InnoDB: Compressed tables use zlib 1.2.8
160620 8:59:13 InnoDB: Using Linux native AIO
160620 8:59:13 InnoDB: Initializing buffer pool, size = 16.0M
160620 8:59:13 InnoDB: Completed initialization of buffer pool
160620 8:59:13 InnoDB: highest supported file format is Barracuda.
InnoDB: The log sequence number in ibdata files does not match
InnoDB: the log sequence number in the ib_logfiles!
160620 8:59:13 InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
InnoDB: Database page corruption on disk or a failed
InnoDB: file read of page 661.
InnoDB: You may have to recover from a backup.
160620 8:59:13 InnoDB: Page dump in ascii and hex (16384 bytes):
后面是一堆乱码》》》?
是需要 recover from a backup.吗?
求教下一步怎么办
ThreeBody
2016-06-20 11:38:37 +08:00
df 看看是不是空间满了
scys
2016-06-20 11:39:40 +08:00
和 @9hills 说的一样,文件损坏了,你备份了吗?
Tony1ee
2016-06-20 11:41:20 +08:00
@scys 似乎没有过 平时都不管数据库的 ……
9hills
2016-06-20 11:42:04 +08:00
@Tony1ee 数据文件损坏,找备份吧
izoabr
2016-06-20 11:45:58 +08:00
我记得 innoDB 可以修复的,查查文档
izoabr
2016-06-20 11:48:30 +08:00
http://www.downcc.com/tech/4842.html

参考一下这个,确认是不是类似,但修复之前记得把这个坏的先 tar 一个备份。
majunbo
2016-06-20 11:50:41 +08:00
楼主,我周 6 也碰到跟你类似的问题:
Thread pointer: 0x0
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 0 thread_stack 0x40000
/usr/local/mysql/bin/mysqld(my_print_stacktrace+0x35)[0x79e385]
/usr/local/mysql/bin/mysqld(handle_fatal_signal+0x403)[0x66e113]
/lib64/libpthread.so.0[0x33fc60eca0]
/lib64/libc.so.6(gsignal+0x35)[0x33fba30265]
/lib64/libc.so.6(abort+0x110)[0x33fba31d10]
/usr/local/mysql/bin/mysqld[0x8adda6]
/usr/local/mysql/bin/mysqld[0x8993f6]
/usr/local/mysql/bin/mysqld[0x817a0f]
/usr/local/mysql/bin/mysqld[0x7ccf73]
/usr/local/mysql/bin/mysqld[0x8b551b]
/usr/local/mysql/bin/mysqld[0x8b5ec4]
/usr/local/mysql/bin/mysqld[0x8ab55d]
/usr/local/mysql/bin/mysqld[0x7eb525]
/usr/local/mysql/bin/mysqld[0x7e05b8]
/lib64/libpthread.so.0[0x33fc60683d]

我的解决方案是-----恢复数据库。
Felldeadbird
2016-06-20 14:39:28 +08:00
Mysql 启动不了来来去去问题就是几点:
1.内存不足。 这个再意外崩溃的情况下导致的。这时候需要重启电脑才可以解决。
2.硬盘空间满了,或者 MYSQL 启动进程的挂载空间满了。
3.其他
剩下的就针对解决就好了。。。
PS :平时弄多几台机器做备份和主从。 MYSQL 崩溃起来 哭爹娘没用。
zhouquanbest
2016-06-20 15:30:21 +08:00
这么常见的一个问题 你真的只要 stackoverflow 上搜搜就有一堆答案

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/286970

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX