Mysql
1.Mysql安装配置
Mysql8.0.21安装脚本
Mysql内存优化计算器
Mysql配置检查优化脚本
my.cnf配置详解
CentOS7.6安装Mysql8
mysql8主备安装脚本
2.Mysql日常使用
Mysql慢查询分析
login-path
3.Mysql异常处理
ERROR 1129
ERROR 1040
ERROR 24
ERROR 2006
ERROR 145
本文档使用 MrDoc 发布
-
+
首页
ERROR 145
# ERROR 145 (HY000) ## 异常 1. 今天某网站突然无法访问,使用的是Mysql数据库,Laravel应用抛出的异常信息如下: ```sql exception 'Illuminate\Database\QueryException' with message 'SQLSTATE[HY000]: General error: 145 Table './2019/tracker_sessions' is marked as crashed and should be repaired ``` ## 检查数据库 2. 检查后发现,数据库默认虽然是Innodb引擎,但是表实际上使用的是Myisam引擎。 ```sql # 查看数据库存储引擎 mysql> show engines; +--------------------+---------+----------------------------------------------------------------+--------------+------+------------+ | Engine | Support | Comment | Transactions | XA | Savepoints | +--------------------+---------+----------------------------------------------------------------+--------------+------+------------+ | FEDERATED | NO | Federated MySQL storage engine | NULL | NULL | NULL | | MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO | | MyISAM | YES | MyISAM storage engine | NO | NO | NO | | BLACKHOLE | YES | /dev/null storage engine (anything you write to it disappears) | NO | NO | NO | | CSV | YES | CSV storage engine | NO | NO | NO | | MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO | | ARCHIVE | YES | Archive storage engine | NO | NO | NO | | InnoDB | DEFAULT | Supports transactions, row-level locking, and foreign keys | YES | YES | YES | | PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO | +--------------------+---------+----------------------------------------------------------------+--------------+------+------------+ 9 rows in set (0.00 sec) # 查看建表语句 mysql> show create table tracker_sessions; +------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | tracker_sessions | CREATE TABLE `tracker_sessions` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `uuid` varchar(191) NOT NULL, `user_id` bigint(20) unsigned DEFAULT NULL, `device_id` bigint(20) unsigned DEFAULT NULL, `agent_id` bigint(20) unsigned DEFAULT NULL, `client_ip` varchar(191) NOT NULL, `referer_id` bigint(20) unsigned DEFAULT NULL, `cookie_id` bigint(20) unsigned DEFAULT NULL, `geoip_id` bigint(20) unsigned DEFAULT NULL, `is_robot` tinyint(1) NOT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL, `language_id` bigint(20) unsigned DEFAULT NULL, `user_agent` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) USING BTREE, UNIQUE KEY `tracker_sessions_uuid_unique` (`uuid`) USING BTREE, KEY `tracker_sessions_user_id_index` (`user_id`) USING BTREE, KEY `tracker_sessions_device_id_index` (`device_id`) USING BTREE, KEY `tracker_sessions_agent_id_index` (`agent_id`) USING BTREE, KEY `tracker_sessions_client_ip_index` (`client_ip`) USING BTREE, KEY `tracker_sessions_referer_id_index` (`referer_id`) USING BTREE, KEY `tracker_sessions_cookie_id_index` (`cookie_id`) USING BTREE, KEY `tracker_sessions_geoip_id_index` (`geoip_id`) USING BTREE, KEY `tracker_sessions_created_at_index` (`created_at`) USING BTREE, KEY `tracker_sessions_updated_at_index` (`updated_at`) USING BTREE, KEY `tracker_sessions_language_id_index` (`language_id`) USING BTREE ) ENGINE=MyISAM AUTO_INCREMENT=825949 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC | +------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec) ``` ## 修复表 3. 可以使用myisamchk工具来修复该表。 ```shell [root@www logs]# cat /etc/my.cnf |grep data datadir = /usr/local/mysql/var [root@www logs]# myisamchk -c -r /usr/local/mysql/var/2019/tracker_sessions Warning: Using unique option prefix read_buffer instead of read_buffer_size is deprecated and will be removed in a future release. Please use the full name instead. Warning: Using unique option prefix write_buffer instead of write_buffer_size is deprecated and will be removed in a future release. Please use the full name instead. - recovering (with sort) MyISAM-table 'tracker_sessions' Data records: 825669 - Fixing index 1 - Fixing index 2 825000 ``` 4. 或使用sql命令修复该表 ```sql mysql> repair table 2019.tracker_sessions; +-----------------------+--------+----------+----------+ | Table | Op | Msg_type | Msg_text | +-----------------------+--------+----------+----------+ | 2019.tracker_sessions | repair | status | OK | +-----------------------+--------+----------+----------+ ``` 5. 完成 修复完成后记得检查业务是否正常。
zhangky
2021年5月31日 13:20
分享文档
收藏文档
上一篇
下一篇
微信扫一扫
复制链接
手机扫一扫进行分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码