pt-online-schema-change使用

本文详细介绍了pt-online-schema-change工具的安装方法、命令行参数及其使用示例,包括如何进行在线表结构变更,以及命令中关键参数的含义。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

pt-online-schema-change工具需要先安装percona-toolkit 工具包(下载地址:https://www.percona.com/downloads/percona-toolkit/),

示例:(验证通过)

IP地址:112.74.194.66  mysql用户名:root  mysql密码:123456 数据库名:998pu 表名称:t_sys_params

#pt-online-schema-change -h 112.74.194.66 -P 3306 -u root -p 123456  --alter="add column c1 int" --execute  D=998pu,t=t_sys_params

具体参数参考命令行的帮助说明,如下:

#pt-online-schema-change  --help


命令要点:

1、Usage: pt-online-schema-change [OPTIONS] DSN

OPTIONS:是可选项,命令必须带DSN


2、 --dry-run and --execute are mutually exclusive.

OPTIONS参数中的--dry-run 和 --execute 参数,同时只能选择一个,--dry-run:不建立触发器,不拷贝数据,不替代原表;只是创建和更改新表。


3、DSN syntax is key=value[,key=value...] 

关键字之前使用逗号分隔开,使用空格不能识别

allowable DSN keys:
  KEY  COPY  MEANING
  ===  ====  =============================================
  A    yes   Default character set
  D    yes   Database for the old and new table
  F    yes   Only read default options from the given file
  P    yes   Port number to use for connection
  S    yes   Socket file to use for connection
  h    yes   Connect to host
  p    yes   Password to use when connecting
  t    no    Table to alter
  u    yes   User for login if not current user

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值