mysql快速生成测试数据

mysql版本:5.7.28

 

创建测试表

CREATE TABLE `t2` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`col1` int(11) DEFAULT NULL,
`col2` bigint(20) DEFAULT NULL,
`col3` text,
`col4` varchar(30) DEFAULT NULL,
`col5` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `un_index` (`col1`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

 

下载工具包

https://github.com/Percona-Lab/mysql_random_data_load/releases/download/v0.1.12/mysql_random_data_load_0.1.12_Linux_x86_64.tar.gz

 

解压

tar zxf mysql_random_data_load_0.1.12_Linux_x86_64.tar.gz

 

直接运行

[root@localhost ~]# ./mysql_random_data_load -h127.0.0.1 -umsandbox -pmsandbox -P5728 --max-threads=4 test1 t2 1000000
INFO[2021-01-08T14:14:50+08:00] Starting
2m41s [====================================================================] 100%
INFO[2021-01-08T14:17:34+08:00] 1000000 rows inserted

 

生成的数据如下

msandbox@localhost 127.0.0.1 15:26:  test1>select * from t2 limit 1 \G
*************************** 1. row ***************************
  id: 1
col1: 583532949
col2: 8674665223082153551
col3: hic voluptatem dolor beatae consectetur nemo placeat.
col4: voluptatem et voluptas.
col5: 2020-11-13 13:01:02
1 row in set (0.00 sec)

 

posted @ 2021-01-08 15:31  王2  阅读(267)  评论(0编辑  收藏  举报