ERROR 145 (HY000): Table './group4/group323' is marked as crashed and should be repaired
...
line = cur.execute(sql)
File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 161, in execute
r = self._query(query)
line = cur.execute(sql)
File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 174, in execute
self.errorhandler(self, exc, value)
File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue
KeyboardInterrupt
...
_mysql_exceptions.InternalError: (145, "Table './group4/group339' is marked as crashed and should be repaired")
今天在python-mysqldb中查询遇到的问题,数据是从windows上MS SQL 转为Mysql(MyISAM)的,数据直接挂载到目录下就能用。
但是查询的时候没有反映,也不报错,没有任何提示,想了想延时的问题,但是延时只能在链接的时间添加参数 onnect_timeout,execute不支持查询查询超市,除非在数据库中直接设置超时配置。
然后把这句话拷贝的数据库中试了试,
mysql> use group4;select um from group323 where Num = 32217473;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
^CCtrl-C -- exit!
Aborted
加上-A(不预读数据库)
mysql -uroot -p -A
mysql> use group4;select um from group323 where Num = 32217473;
Database changed
^CCtrl-C -- sending "KILL QUERY 786" to server ...
Ctrl-C -- query aborted.
ERROR 1317 (70100): Query execution was interrupted
mysql> select QQNum as qq from group323 where QunNum = 32217473;
^CCtrl-C -- sending "KILL QUERY 786" to server ...
Ctrl-C -- query aborted.
ERROR 145 (HY000): Table './group4/group323' is marked as crashed and should be repaired
mysql> select um from group323 where Num = 32217473;
^CCtrl-C -- sending "KILL QUERY 786" to server ...
Ctrl-C -- query aborted.
ERROR 1317 (70100): Query execution was interrupted
查了查145的原因,是因为索引文件损坏了,需要修复。
root@ubuntu:~#:
myisamchk -c -r /var/lib/mysql/group4/group323.MYI
- recovering (with keycache) MyISAM-table '/var/lib/mysql/group4/group323.MYI'
Data records: 1395199
mysql> select um from group323 where Num = 32217473;
+-----------+
|
um
|
+-----------+
| 543057109 |
| 772193283 |
| 331913702 |
| 903525121 |
| 632300180 |
| 772687572 |
|
83959572 |
| 875214751 |
| 125599972 |
| 514400286 |
| 471481228 |
| 312371026 |
| 574164513 |
| 582299288 |
+-----------+
14 rows in set (0.00 sec)
搞定了,虽然没有加-A参数,也提示Reading table information for completion of table and column names,You can turn off this feature to get a quicker startup with -A。但是很快就提示了Database changed。