【原创】Mysql ERROR 14…

本文记录了一次使用Python MySQLdb查询过程中遇到的表标记为崩溃并需要修复的问题。通过检查索引文件并使用myisamchk工具成功解决了问题。
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)
KeyboardInterrupt

...
    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
_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。
<?php session_start(); include "Conn/conn.php"; include "page.php"; ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <title>博文列表</title> <link rel="stylesheet" href="CSS/list.css"/> <link href="CSS/index.css" rel="stylesheet"/> </head> <body style=" background-color:#F1F2F6;"> <div class="banner"> <div class="nav"> <a class="left" href="index.php">博客系统</a> <div class="right"> <?php if(isset($_SESSION['username'])) { ?> <a class="a" href="./myinfo.php">个人中心</a> <a class='a' href='#'> | </a> <a class="a" href="./doAction.php?a=loginout">安全退出</a> <?php }else { ?> <a class='a' href='./login.php'>登录</a> <a class='a' href='#'> | </a> <a class='a' href='./Register.php'>注册</a> <?php } ?> </div> </div> </div> <div class="bgimg"></div> <div id="big" style="margin-top: -50px;border-radius:5px;"> <div id="list"> <div id="listbt"> <div id="bkname"> <h4>博文列表</h4> </div> <div id="bzname"> <h4>博主:<?php echo $_SESSION['username']?></h4> </div> </div> <div id="bkinfo"> <div id="bklogo"> <img src="images/PHP.png"/> </div> <div id="tjinfo"></div> <div id="bkjianj"> <?php $sql="select sign from tb_userdetail where userid={$_SESSION['uid']}"; $result = mysqli_query($link,$sql); foreach($result as $v){ echo "<p>".$v['sign']."</p>"; } ?> </div> </div> <div id="biaotou"> <ul> <li class="tiezibt" style="width: 550px;"><a href="#">标题</a></li> <li><a href="#">作者</a></li> <li><a href="#">操作</a></li> <li><a href="#">发表时间</a></li> </ul> </div> <?php $sql="select * from tb_article where author='$_SESSION[username]'"; $result=mysqli_query($link,$sql); $rows = $result->num_rows; Page($rows,2); $sql = "select * from tb_article where author='$_SESSION[username]' order by id desc limit $select_from $select_limit"; $result=mysqli_query($link,$sql); if($result && mysqli_num_rows($result)>0){ while($rows=mysqli_fetch_assoc($result)){ ?> <div id="listks"> <div class="invitationzt"> <div class="invitalogo"> </div> <div class="invitationbt"> <a href="./file_show.php?id=<?php echo $rows['id']?>"><?php echo $rows['title']?></a> </div> <div class="custor"> <a href="#"><?php echo $rows['author']?></a> </div> <div class="reply"> <a href="./doAction.php?a=del_file&id=<?php echo $rows['id']?>" onclick="return confirm('确定将此记录删除?')">删除</a>| <a href="./file.php?a=edit_file&id=<?php echo $rows['id']?>">编辑</a> </div> <div class="last"> <?php echo date("Y-m-d",$rows['time'])?> </div> </div> </div> <?php } } ?> <div id="page" style="text-align: center;"> <div id="pagefy" style="margin: 0 auto;"> <ul> <?php echo $pagenav;?> </ul> </div> </div> </div> </div> <div id="clear"></div> <?php include "footer.php"; ?> </body> </html>在该代码中,foreach($result as $v){报错,修改并输出
最新发布
06-05
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值