mysql util_新特性解读 | MySQL 8.0 shell util 特性

作者:杨涛涛

本文介绍 MySQL8.0 shell 子模块 Util 的两个导入特性 importTable/import_table(JS和python 版本的命名差异)、importJson/import_json的使用方法。其中import_table 是通过传统 MySQL 协议来通信,Import_json 是通过 X 插件协议来通信。

MySQL 一直以来提供导入文件 SQL 命令 load data infile(单线程)以及对应的可执行文件 mysqlimport(多线程),比如我导入 100W 行示例数据到表 ytt.tl1, 花了 24 秒。这个已经是 MySQL 默认导入来的最快的。

[root@mysql-dev ytt]# time mysqlimport --login-path=ytt_master --fields-terminated-by=, --use-threads=4 ytt /var/lib/mysql-files/tl1.csv

ytt.tl1: Records: 1048576 Deleted: 0 Skipped: 0 Warnings: 0

real 0m24.815s

user 0m0.013s

sys 0m0.031s

那我们现在看下 mysqlimport 工具的升级版,mysqlshell 的 util 工具集。使用这两个工具之前,必须得临时开启 local_infile 选项。

1.import_table

[root@mysql-dev ytt]# mysqlsh

MySQL Shell 8.0.17

Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its affiliates.

Other names may be trademarks of their respective owners.

Type '\help' or '\?' for help; '\quit' to exit.

建立 3306 端口的新连接

MySQL JS > \c admin@127.0.0.1:3306

Creating a session to 'admin@127.0.0.1:3306'

Fetching schema names for autocompletion... Press ^C to stop.

Your MySQL connection id is 56

Server version: 8.0.17 MySQL Community Server - GPL

No default schema selected; type \use to set one.

我这里切换为 python 模式

MySQL 127.0.0.1:3306 ssl JS > \py

Switching to Python mode...

MySQL 127.0.0.1:3306 ssl Py > \us

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值