mysqlcheck

news2024/9/24 19:20:57

mysql bin中的其他工具包 

对于mysql的其他工具, 有很多选项是公共的, 例如你在对数据库进行检查的时候, 需要指定host和user以及其password来连接上mysqlserver来进行相关操作, 这个时候其实用到的host等东西跟我们之前的mysql-client其实是类似的

也就是说他们是作为mysql众多工具的公共选项的, mysqlclient可以用, mysqlcheck也能用.. 

下面是一些公用的选项 .. 

公共选项
长选项简写说明
--host-h--host=127.0.0.1 或者 -h 127.0.0.1
--port-P (注意是大写)--port=port_num , -P port_num (TCP/IP 连接使⽤的端⼝号)
--user-u--user username , -uusername, -u username, 是用于连接到mysql服务器的用户名
--password-p (注意是小写)指定登录的mysql对应用户的密码
--defaults-file使⽤指定的选项⽂件。如果该⽂件不存在,则会发⽣错误
--compress-C如果可能,压缩客⼾端和服务器之间传输的所有信息
--protocol⽤于连接到服务器的传输协议, 默认为TCP
--version-V显⽰版本信息并退出
--help-?显⽰帮助信息并退出
C:\Users\23863>mysqlcheck -V
mysqlcheck  Ver 8.0.37 for Win64 on x86_64 (MySQL Community Server - GPL)

mysqlcheck 是一种表维护程序

mysqlcheck客户端用于执行表维护, 可以对表进行分析, 检查, 优化或者修复操作.

  • 分析 查看表的关键字的分布, 能够让sql生成正确的执行计划, 支持innodb, myisam
  • 检查, 检查表的完整性以及数据库表或者索引是否损坏, 支持innodb和myisam
  • 优化的作用是优化空间, 减少碎片, 提高io, 支持innodb, myisam
  • 修复是指的修复已经损坏的表, 支持innodb, myisam.

注意

  • mysqlcheck需要mysqlserver处于运行状态
  • 执行过程中, 相应的表将会被锁定, 其他所有的操作将会被阻塞
  • 并不是所有的存储引擎都支持mysqlcheck.
  • 执行表修复之前必须备份, 在某些情况下可能会造成数据丢失.

使用方法

你一般可以用下面这三种方法来使用mysqlcheck

mysqlcheck [options] db_name [tbl_name ...]
mysqlcheck [options] --databases db_name ...
mysqlcheck [options] --all-databases

mysqlcheck就是mysqlcheck.exe, 可以通过options来指定选项, 然后后面什么db_name之类的就是选择数据库和表的策略了

这里有几个你需要注意的: 

  • 如果你不指定db_name下的任何tbl_name, 或者是你使用--databases, 亦或是--all-databases选项, 整个数据库(所有的database)将会被检查, 如下: 
mysqlcheck [options] db_name
mysqlcheck [options] --databases
mysqlcheck [options] --all-databases

例如, 我有如下数据库:

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| phoebe             |
| sys                |
| tethys             |
| wangyiyun          |
+--------------------+
7 rows in set (0.01 sec)

首先如果我只是指定一个数据库名(phoebe): 

C:\Users\23863>mysqlcheck -a phoebe -uroot -p
Enter password: ****
phoebe.car                                         OK
phoebe.car_check                                   OK
phoebe.car_check_config                            OK
phoebe.car_check_record                            OK
phoebe.car_delivery_info                           OK
phoebe.car_driver                                  OK
phoebe.car_driver_record                           OK
phoebe.car_parts                                   OK
phoebe.car_price                                   OK
phoebe.car_price_weight                            OK
phoebe.car_report                                  OK
phoebe.car_specs                                   OK
phoebe.car_type                                    OK
phoebe.car_used_time_record                        OK
phoebe.department_quota_config                     OK
phoebe.driver_up_down_record                       OK
phoebe.flyway_schema_history                       OK
phoebe.item                                        OK
phoebe.item_cost_type                              OK
phoebe.item_department                             OK
phoebe.item_job_content                            OK
phoebe.item_machine                                OK
phoebe.item_part                                   OK
phoebe.item_process                                OK
phoebe.item_process_detail                         OK
phoebe.message                                     OK
phoebe.option_config                               OK
phoebe.order_adjust_record                         OK
phoebe.order_approval                              OK
phoebe.order_driver_record                         OK
phoebe.order_evaluate                              OK
phoebe.order_submit                                OK
phoebe.orders                                      OK
phoebe.region                                      OK
phoebe.user_role                                   OK

如果我使用--databases 然后指定phoebe

发现check了phoebe的所有table: 

C:\Users\23863>mysqlcheck -a --databases phoebe -uroot -p
Enter password: ****
phoebe.car                                         OK
phoebe.car_check                                   OK
phoebe.car_check_config                            OK
phoebe.car_check_record                            OK
phoebe.car_delivery_info                           OK
phoebe.car_driver                                  OK
phoebe.car_driver_record                           OK
phoebe.car_parts                                   OK
phoebe.car_price                                   OK
phoebe.car_price_weight                            OK
phoebe.car_report                                  OK
phoebe.car_specs                                   OK
phoebe.car_type                                    OK
phoebe.car_used_time_record                        OK
phoebe.department_quota_config                     OK
phoebe.driver_up_down_record                       OK
phoebe.flyway_schema_history                       OK
phoebe.item                                        OK
phoebe.item_cost_type                              OK
phoebe.item_department                             OK
phoebe.item_job_content                            OK
phoebe.item_machine                                OK
phoebe.item_part                                   OK
phoebe.item_process                                OK
phoebe.item_process_detail                         OK
phoebe.message                                     OK
phoebe.option_config                               OK
phoebe.order_adjust_record                         OK
phoebe.order_approval                              OK
phoebe.order_driver_record                         OK
phoebe.order_evaluate                              OK
phoebe.order_submit                                OK
phoebe.orders                                      OK
phoebe.region                                      OK
phoebe.user_role                                   OK

 -- 提示

你无法在使用--databases的时候不指定db_name :

C:\Users\23863>mysqlcheck -a --databases -uroot -p
You forgot to give the arguments! Please see mysqlcheck --help
for more information.

--all-databases : 

可以看到扫描了所有的数据库的所有表

C:\Users\23863>mysqlcheck -a --all-databases -uroot -p
Enter password: ****
mysql.columns_priv                                 OK
mysql.component                                    OK
mysql.db                                           OK
mysql.default_roles                                OK
mysql.engine_cost                                  OK
mysql.func                                         OK
mysql.general_log
note     : The storage engine for the table doesn't support analyze
mysql.global_grants                                OK
mysql.gtid_executed                                OK
mysql.help_category                                OK
mysql.help_keyword                                 OK
mysql.help_relation                                OK
mysql.help_topic                                   OK
mysql.innodb_index_stats                           OK
mysql.innodb_table_stats                           OK
mysql.ndb_binlog_index                             OK
mysql.password_history                             OK
mysql.plugin                                       OK
mysql.procs_priv                                   OK
mysql.proxies_priv                                 OK
mysql.replication_asynchronous_connection_failover OK
mysql.replication_asynchronous_connection_failover_managed OK
mysql.replication_group_configuration_version      OK
mysql.replication_group_member_actions             OK
mysql.role_edges                                   OK
mysql.server_cost                                  OK
mysql.servers                                      OK
mysql.slave_master_info                            OK
mysql.slave_relay_log_info                         OK
mysql.slave_worker_info                            OK
mysql.slow_log
note     : The storage engine for the table doesn't support analyze
mysql.tables_priv                                  OK
mysql.time_zone                                    OK
mysql.time_zone_leap_second                        OK
mysql.time_zone_name                               OK
mysql.time_zone_transition                         OK
mysql.time_zone_transition_type                    OK
mysql.user                                         OK
phoebe.car                                         OK
phoebe.car_check                                   OK
phoebe.car_check_config                            OK
phoebe.car_check_record                            OK
phoebe.car_delivery_info                           OK
phoebe.car_driver                                  OK
phoebe.car_driver_record                           OK
phoebe.car_parts                                   OK
phoebe.car_price                                   OK
phoebe.car_price_weight                            OK
phoebe.car_report                                  OK
phoebe.car_specs                                   OK
phoebe.car_type                                    OK
phoebe.car_used_time_record                        OK
phoebe.department_quota_config                     OK
phoebe.driver_up_down_record                       OK
phoebe.flyway_schema_history                       OK
phoebe.item                                        OK
phoebe.item_cost_type                              OK
phoebe.item_department                             OK
phoebe.item_job_content                            OK
phoebe.item_machine                                OK
phoebe.item_part                                   OK
phoebe.item_process                                OK
phoebe.item_process_detail                         OK
phoebe.message                                     OK
phoebe.option_config                               OK
phoebe.order_adjust_record                         OK
phoebe.order_approval                              OK
phoebe.order_driver_record                         OK
phoebe.order_evaluate                              OK
phoebe.order_submit                                OK
phoebe.orders                                      OK
phoebe.region                                      OK
phoebe.user_role                                   OK
sys.sys_config                                     OK
sys.user                                           OK
tethys.anno_aim                                    OK
tethys.announce_safe                               OK
tethys.announcement                                OK
tethys.approve_request                             OK
tethys.approve_step                                OK
tethys.carts                                       OK
tethys.check                                       OK
tethys.check_detail                                OK
tethys.course                                      OK
tethys.course_aim                                  OK
tethys.course_theme                                OK
tethys.customer_feedback                           OK
tethys.customer_record                             OK
tethys.delivery_quantity_chart                     OK
tethys.delivery_quantity_record                    OK
tethys.delivery_rate_chart                         OK
tethys.department                                  OK
tethys.device                                      OK
tethys.device_usage_detail                         OK
tethys.device_usage_record                         OK
tethys.distribution_list                           OK
tethys.drawing_head                                OK
tethys.flyway_schema_history                       OK
tethys.forklift                                    OK
tethys.inventory_check                             OK
tethys.inventory_check_remarks                     OK
tethys.leader_board                                OK
tethys.maintenance_record                          OK
tethys.material                                    OK
tethys.menu                                        OK
tethys.message                                     OK
tethys.order_completed                             OK
tethys.order_enterstore                            OK
tethys.order_enterstore_comments                   OK
tethys.order_enterstore_material                   OK
tethys.order_item                                  OK
tethys.order_sendgoods                             OK
tethys.orders                                      OK
tethys.organization                                OK
tethys.product                                     OK
tethys.project_schedule                            OK
tethys.remark                                      OK
tethys.repair_record                               OK
tethys.role                                        OK
tethys.role_menu                                   OK
tethys.score                                       OK
tethys.score_change                                OK
tethys.shift_records                               OK
tethys.shuttle_car_dist                            OK
tethys.site                                        OK
tethys.special_bill_package                        OK
tethys.special_car_dist                            OK
tethys.station_info                                OK
tethys.supplier                                    OK
tethys.transhipment_bill                           OK
tethys.transhipment_bill_detail                    OK
tethys.transhipment_time                           OK
tethys.tray                                        OK
tethys.tray_item                                   OK
tethys.user                                        OK
tethys.user_backup                                 OK
tethys.user_role                                   OK
tethys.violation                                   OK
tethys.warehouse                                   OK
tethys.work_log                                    OK
wangyiyun.singer_info                              OK
wangyiyun.song_comment                             OK
wangyiyun.song_info                                OK

mysqlcheck -- options

参考所有的选项: 

MySQL :: MySQL 8.0 Reference Manual :: 6.5.3 mysqlcheck — A Table Maintenance Program

 常用: 

  • --analyze  或者-a  : 分析指定的数据库和表
  • --auto-repair, 如果你的表已经损坏, 那么就自动修复它(所有的修复将会在所有的指定的表被检查完之后执行)
  • --check, -c , 检查你的表中的错误这是默认的操作, 如果你不指定任何options
C:\Users\23863>mysqlcheck --all-databases -uroot -p
Enter password: ****
mysql.columns_priv                                 OK
mysql.component                                    OK
mysql.db                                           OK
mysql.default_roles                                OK
mysql.engine_cost                                  OK

..... 
  • --check-only-changed,- C, 仅检查⾃上次检查以来更改过的表
  • --databases,-B, --databases db_name 多个数据库名⽤空格隔开 处理指定数据库中的所有表
  • --force, -f 即使发⽣SQL错误也要继续
  • --optimize,-o 优化表 (注意是否支持innodb)
  • --repair,-r 执⾏可能进⾏的任务修复操作,除了唯⼀键
  • --skip-database --skip-database=db_name 不需要执⾏检查的数据库名(区分⼤⼩写)
  • --tables --tables=table_name 多个表名⽤空格隔开 在选项之后的所有名称参数都被视为表名
  • --use-frm 对于MyISAM表的修复操作

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2070788.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

顺序表的顺序表示—动态分配

顺序表的顺序表示—动态分配 代码实现 #include <stdio.h> #include <stdlib.h> #define InitSize 15 // 初始化扩容长度typedef struct{int *data; // 动态分配数组的指针int MaxSize;int length; // 当前长度 }SeqList;void InitList(SeqList &L){// 申请一…

C++不同数据类型连接成一个字符串

在C中数据连接的方式使用号进行连接。 1.都是字符型时直接使用连接几个字符串&#xff1b; 2.不是字符类型时&#xff0c;要用to_string函数转换后再连接。

做空股指期货一手多少钱?

股指期货的保证金比例是12%-15%不等&#xff0c;所以做空一手股指期货的保证金最少是要十几万元&#xff0c;部分平台两万。关于做空一手股指期货的具体金额&#xff0c;这并非固定不变&#xff0c;而是会根据市场的实时价格、合约的乘数以及交易所的规定等因素而有所变动。 股…

Verilog刷题笔记59

题目: Exams/m2014 q6c 解题&#xff1a; module top_module (input [6:1] y,input w,output Y2,output Y4);assign Y2y[1]&w0;assign Y4(y[2]&w1)|(y[3]&w1)|(y[5]&w1)|(y[6]&w1);endmodule结果正确: 注意点: 起初&#xff0c;我的代码有错误,代码如下…

快速判断一个项目是Spring MVC框架还是Spring Boot框架

1. 查看项目的启动类 Spring Boot: 通常有一个主类&#xff0c;包含 SpringBootApplication 注解&#xff0c;并且有一个 main 方法来启动应用程序。 SpringBootApplication public class Application {public static void main(String[] args) {SpringApplication.run(Appli…

探索数据结构:图(三)之最短路径算法

✨✨ 欢迎大家来到贝蒂大讲堂✨✨ &#x1f388;&#x1f388;养成好习惯&#xff0c;先赞后看哦~&#x1f388;&#x1f388; 所属专栏&#xff1a;数据结构与算法 贝蒂的主页&#xff1a;Betty’s blog 1. 最短路径算法 最短路径问题可分为单源最短路径和多源最短路径。其指…

如何使用ssm实现珠宝首饰交易平台开发

TOC ssm101珠宝首饰交易平台开发jsp 第一章 绪 论 1.1背景及意义 系统管理也都将通过计算机进行整体智能化操作&#xff0c;对于珠宝首饰交易平台所牵扯的管理及数据保存都是非常多的&#xff0c;例如管理员&#xff1b;主页、个人中心、用户管理、商品分类管理、商品信息管…

【Material-UI】Radio Group中的 Label Placement 属性详解

文章目录 一、Radio Group 组件概述1. 组件介绍2. Label Placement 属性的作用 二、Label Placement 属性的基本用法三、Label Placement 属性详解1. 标签位置的选择2. 如何在实际项目中选择标签位置 四、Label Placement 属性的实际应用场景1. 表单布局中的应用2. 符合用户习惯…

多进程多线程及之间通信机制

目录 前言 一、多进程与多线程 1. 多进程 多进程的特点 多进程的应用场景 2. 多线程 多线程的特点 多线程的应用场景 3. 多进程与多线程的对比 二、进程与线程之间的通信机制 1. 进程间通信&#xff08;IPC, Inter-Process Communication&#xff09; 2. 线程间通信…

Golang | Leetcode Golang题解之第365题水壶问题

题目&#xff1a; 题解&#xff1a; type pair struct {x, y int }func canMeasureWater(jug1Capacity int, jug2Capacity int, targetCapacity int) bool {//剪枝if jug1Capacityjug2Capacity < targetCapacity {return false}var (dfs func(x, y int) bool // jug1有x水…

NC包含min函数的栈

系列文章目录 文章目录 系列文章目录前言 前言 前些天发现了一个巨牛的人工智能学习网站&#xff0c;通俗易懂&#xff0c;风趣幽默&#xff0c;忍不住分享一下给大家。点击跳转到网站&#xff0c;这篇文章男女通用&#xff0c;看懂了就去分享给你的码吧。 描述 定义栈的数据…

基于STM32开发的智能水箱液位控制系统

目录 引言环境准备工作 硬件准备软件安装与配置系统设计 系统架构硬件连接代码实现 系统初始化液位监测与控制水泵控制与状态显示Wi-Fi通信与远程监控应用场景 家庭用水系统的液位控制工业水箱的液位管理常见问题及解决方案 常见问题解决方案结论 1. 引言 智能水箱液位控制系…

线程池详解(建议收藏)

概念 线程池&#xff08;Thread Pool&#xff09;是一种基于池化技术的多线程处理形式&#xff0c;用于管理线程的创建和生命周期&#xff0c;以及提供一个用于并行执行任务的线程队列。线程池的主要目的是减少在创建和销毁线程时所花费的开销和资源&#xff0c;提高程序性能&…

C# messagePack对类(class)序列化简单示例

c# messagepack对类&#xff08;class&#xff09;序列化的简单示例 0 引言1 示例2 纠错3 结语 0 引言 MessagePack是一种高效的二进制序列化格式&#xff0c;它可以在C#中用于序列化和反序列化对象。与其他序列化格式相比&#xff0c;如JSON和XML&#xff0c;MessagePack的编…

西安电子高速PCB学习(五)

感抗&#xff08;Inductive Reactance&#xff09;和容抗&#xff08;Capacitive Reactance&#xff09;是电感和电容在交流电路中对电流产生阻碍的特性。这两个概念源于交流电路中&#xff0c;电感和电容对交流电流的相应反应。 感抗&#xff08;Inductive Reactance&#xf…

如何使用ssm实现电脑配件销售系统的设计与实现

TOC ssm128电脑配件销售系统的设计与实现jsp 第一章 绪 论 1.1背景及意义 系统管理也都将通过计算机进行整体智能化操作&#xff0c;对于电脑配件销售系统所牵扯的管理及数据保存都是非常多的&#xff0c;例如管理员&#xff1b;主页、个人中心、用户管理、商品分类管理、商…

PyTorch升级之旅——主要组成模块

本文仅作为个人学习记录使用 文章目录 前言 一、深度学习的简单流程 二、基本配置 三、数据读入 四、模型构建 五、模型初始化 六、损失函数 七、训练和评估 八、可视化 九、PyTorch优化器 总结 前言 学习链接&#xff1a;第三章&#xff1a;PyTorch的主要组成模块…

推荐几个缓解工作心情的VS Code插件

vs-cats 使用了这个插件&#xff0c;在写到"cat"/"Cat"单词时&#xff0c;可以在单词左边出现猫猫表情&#xff0c;而且在鼠标停靠在单词附近时还能显示猫猫图片 vscode-pets 使用这个插件可以在VS Code中养很多电子小动物&#xff0c;可以饲养的宠物有&a…

跟《经济学人》学英文:2024年08月24日这期 How to attract Indian tourists

How to attract Indian tourists Destinations are competing for the travelling rupee 原文&#xff1a; INDIANS ARE on the move. In 2019 international departures from India hit 27m, a number that will surely be exceeded this year and is predicted to rise t…

2024年好用的4款电脑录屏工具清单。

如果你需要录制教学视频、操作演示、记录游戏等等&#xff0c;但不知道使用哪些软件可以实现&#xff0c;那你一定要看看这个文章。因为我帮助大家筛选了4款能够用于电脑屏幕录制的高效工具。 1、福昕电脑REC 直达&#xff1a;www.foxitsoftware.cn/REC/ 这个软件是很多必备的…