Skip to content

Instantly share code, notes, and snippets.

从 mysql 导出到 pg

# vim my.load
LOAD DATABASE
         FROM      mysql://root:123.123@192.168.1.125:3307/demo_db?useSSL=false
         INTO      postgresql://postgres:123123@@123@192.168.1.125:5432/postgres?demo_db
with prefetch rows = 500
WITH include drop, create tables, create indexes, workers = 1, concurrency = 1
;
# 运行

常用(需要先安装fisher)

prompts
  1. tide
# 安装
fisher install IlanCosman/tide@v6
# 配置
tide configure

所有常用插件

常用语句

进程连接
  1. 查看表是否在使用 如果查询结果为空。则证明表没有在使用
show open tables where in_use > 0 ;
  1. 显示用户正在运行的进程 除了 root 用户能看到所有正在运行的进程外,其他用户都只能看到自己正在运行的线程,看不到其它用户正在运行的进程。
show processlist;

数据相关工具

数据库模型建模工具
  1. pdmaner, 蓝奏云下载
数据库连接
  1. dbeaver(推荐,可以连接很多数据库)
  2. navicate (可以比对数据库结构)
  3. DbVisualizer (还没咋使用)
  4. heidisql (小巧)

ssh端口转发 转发的端口:localhost:需要转发的端口

ssh -L  8086:localhost:8086 root@192.168.1.125

iptable端口转发 所有经过63306的流量转发到 192.168.1.2:3306

iptables -t nat -A PREROUTING -p tcp --dport 63306 -j DNAT --to-destination 192.168.1.2:3306

socat端口转发 所有经过81的流量转发到 127.0.0.1:80 应该可以用iptable实现

mysql主从配置

配置主库

1.创建账号
GRANT REPLICATION SLAVE ON *.* TO 'replica_user'@'replica_server_ip';
FLUSH PRIVILEGES;

配置从库

js时间戳转时间

var bind_time = 1713769412106
var d  = new Date(bind_time)

dformat = [d.getMonth()+1,
               d.getDate(),
               d.getFullYear()].join('/')+' '+
              [d.getHours(),
 d.getMinutes(),

pv命令使用

mysql导入数据限速5M

 pv  -L 5m  demo.sql | mysql  -h123 -ufund -pdemo  jydb_pub