↓ Skip to main content
  1. Posts/

database connection error 的解决方案

·854 words·2 mins
Note: This article is available in Chinese only. 本文暂无英文版本。 View original

其实 东西之前出现过…不过好像重启一下服务器就可以了?

这次比较麻烦。

一开始我是直接 google 了这条错误信息,结果答案五花八门,或者说…可能的原因非常多。

排查了几个,还是没有搞定。

突然想到,为何不直接看 log…我好傻啊。

 12016-10-10 10:36:54 3755 [Note] IPv6 is not available.
 22016-10-10 10:36:54 3755 [Note]   - '0.0.0.0' resolves to '0.0.0.0';
 32016-10-10 10:36:54 3755 [Note] Server socket created on IP: '0.0.0.0'.
 42016-10-10 10:36:54 3755 [ERROR] /alidata/server/mysql/bin/mysqld: Table './mysql/user' is marked as crashed and last (automatic?) repair failed
 52016-10-10 10:36:54 3755 [ERROR] Fatal error: Can't open and lock privilege tables: Table './mysql/user' is marked as crashed and last (automatic?) repair failed
 6161010 10:36:54 mysqld_safe mysqld from pid file /alidata/server/mysql/data/iZ287lyogf4Z.pid ended
 7161010 10:42:20 mysqld_safe Starting mysqld daemon with databases from /alidata/server/mysql/data
 82016-10-10 10:42:20 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
 92016-10-10 10:42:20 4118 [Note] Plugin 'FEDERATED' is disabled.
102016-10-10 10:42:20 4118 [Note] InnoDB: Using mutexes to ref count buffer pool pages
112016-10-10 10:42:20 4118 [Note] InnoDB: The InnoDB memory heap is disabled
122016-10-10 10:42:20 4118 [Note] InnoDB: Mutexes and rw_locks use InnoDB's own implementation
132016-10-10 10:42:20 4118 [Note] InnoDB: Memory barrier is not used
142016-10-10 10:42:20 4118 [Note] InnoDB: Compressed tables use zlib 1.2.3
152016-10-10 10:42:20 4118 [Note] InnoDB: Using Linux native AIO
162016-10-10 10:42:20 4118 [Note] InnoDB: Not using CPU crc32 instructions
172016-10-10 10:42:20 4118 [Note] InnoDB: Initializing buffer pool, size = 128.0M
182016-10-10 10:42:20 4118 [Note] InnoDB: Completed initialization of buffer pool
192016-10-10 10:42:20 4118 [Note] InnoDB: Highest supported file format is Barracuda.
202016-10-10 10:42:20 4118 [Note] InnoDB: The log sequence numbers 414871617 and 414871617 in ibdata files do not match the log sequence number 554212530 in the ib_logfiles!
212016-10-10 10:42:20 4118 [Note] InnoDB: Database was not shutdown normally!
222016-10-10 10:42:20 4118 [Note] InnoDB: Starting crash recovery.
232016-10-10 10:42:20 4118 [Note] InnoDB: Reading tablespace information from the .ibd files...
242016-10-10 10:42:20 4118 [Note] InnoDB: Restoring possible half-written data pages
252016-10-10 10:42:20 4118 [Note] InnoDB: from the doublewrite buffer...
26InnoDB: Last MySQL binlog file position 0 92722334, file name mysql-bin.000005
272016-10-10 10:42:20 4118 [Note] InnoDB: 128 rollback segment(s) are active.
282016-10-10 10:42:20 4118 [Note] InnoDB: Waiting for purge to start
292016-10-10 10:42:20 4118 [Note] InnoDB: 5.6.21 started; log sequence number 554212530
302016-10-10 10:42:20 4118 [Note] Recovering after a crash using mysql-bin
312016-10-10 10:42:20 4118 [Note] Starting crash recovery...
322016-10-10 10:42:20 4118 [Note] Crash recovery finished.
332016-10-10 10:42:20 4118 [Note] Server hostname (bind-address): '*'; port: 3306
342016-10-10 10:42:20 4118 [Note] IPv6 is not available.
352016-10-10 10:42:20 4118 [Note]   - '0.0.0.0' resolves to '0.0.0.0';
362016-10-10 10:42:20 4118 [Note] Server socket created on IP: '0.0.0.0'.
372016-10-10 10:42:20 4118 [ERROR] /alidata/server/mysql/bin/mysqld: Table './mysql/user' is marked as crashed and last (automatic?) repair failed
382016-10-10 10:42:20 4118 [ERROR] Fatal error: Can't open and lock privilege tables: Table './mysql/user' is marked as crashed and last (automatic?) repair failed
39161010 10:42:20 mysqld_safe mysqld from pid file /alidata/server/mysql/data/iZ287lyogf4Z.pid ended

发现是说一个表挂掉了。

然后在SO上看到这个stackoverflow

然后惊喜地发现完全不记得数据库密码是啥了…毕竟搭博客的时候我对这些完全没概念…

然后在my.cnf配置文件 加一行 skip-grant-tables 具体位置是在/etc/my.cnf

这样就可以跳过密码直接登录数据库。

查了下果然有问题。

然后用 repair table table_name; 命令修复。

注意 table_name 外面没有引号啊,中括号之类乱七八糟的 2333.

然后再check,发现少了条warning,就是日志里error的那条。

尝试了下访问博客,发现已经可以了,感动到哭。

感觉这次学到的最主要的事情是,出问题直接去找 log,不要从表面的症状来找问题。嗯,感动。

Related

using your computer without mouse

·626 words·2 mins
键盘足够爽了以后。。。 鼠标明显降低效率。。。 学会逐步脱离鼠标吧orz. 首先是chrome插件vimium vimium教程 Vimium 常用的按键功能解释: # 1 * **j:向下细微滚动窗口 k:向上细微滚动窗口** 2 * J:(**Shift+j的意思,以下大写全部表示加Shift)** 下一个标签页 K:上一个标签页 3 * d:向下滚动半个屏幕 u:向上移动半个屏幕 4 * **g+g(连续按两下g):回到顶部** 5 * **G:到达页面底部** 6 * H:后退 L: 前进 7 * f:将当前网页上的所有可见链接/输入框分配一个快捷键,输入后就可以打开或者跳转到对应的输入框。如果按的是F,那么将在新窗口中打开页面(见上图) 8 * g+i:将光标 定位到输入框,如果有多个可以按Tab键切换 9 * x:关闭当前页面 X:恢复刚刚关闭的页面 10 * o:相当于Chrome中的地址栏,可以匹配历史记录、收藏夹并在当前窗口打开,或者直接打开一个网址或者搜索一个关键字(Chrome在全屏的时候地址栏死都出不来,有了它就解决这个一直困扰我的问题了!~),如果按的是O,则可以在新窗口中打开,非常非常方便! 11 * g+s:查看网页的源代码 12 * r:重新载入当前网页(顺便提一句,这点上新浪微博和它是一样的,光标没有定位在发送框时,即便没有安装这个插件你也可以用j/k来控制页面上下滚动,用r在刷新,用f或者p来定位到发送框。而Gmail的快捷键如j,k上下移动光标也是类似,有兴趣大家可以再自己去了解一下一些常用web应用的快捷键)

fedora 24 cannot modify keyboard delay and rate

·176 words·1 min
最近入手了x1 c 然后发现没办法支持 f22….. 没办法,只好上f24了。。。虽然明知道一堆bug… 最近发现。。之前在系统设置->键盘->打字 中的调整键盘延迟和速率的选项。。。不见了。。。

c++11 学习笔记

·172 words·1 min
昨天终于搞定了ycm对c++11的支持…. 嘛,17都快出来了,我竟然连11都不会用。 不过突然把所有的11特性给我也没办法全部吸收。 所以在这里记录下用过的c++11的用法。