---
title: for MySQL
description: "本文以测试MySQL下的TPC-H模型为例。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengdbs/testguide/tstg/kunpenghammerdbforgp_11_0006.html
sourcePath: /source/zh/kunpengdbs/testguide/tstg/kunpenghammerdbforgp_11_0006.html
indexId: 507d4d9be9095fab4ac6f64433f5ad5ac59d85dbe883512f4613044801dd656770
---
# for MySQL

本文以测试MySQL下的TPC-H模型为例。

1. 进入安装路径。
  1 cd HammerDB-3.2

2. 运行测试工具。
  您可以通过help命令查看帮助信息。

  1 ./hammerdbcli

**表1 常用命令介绍**

| 命令 | 说明 |
| --- | --- |
| buildschema | 创建数据库表并按配置导入数据。 |
| datagenrun | 生成tbl数据列表。 |
| dbset | 配置数据库选项，包括数据库类型以及测试模型。 |
| dgset | 配置tbl数据参数，包括生成数据并发数、数据量、以及保存数据的路径。 |
| diset | 配置建表参数，例如数据库服务器地址以及数据库验证信息、数据量等。 |
| librarychek | 运行依赖库校验。 |
| loadscript | 加载测试参数。 |
| print | 打印配置信息。 |
| quit | 退出该工具，在交互页面配置后退出，原配置会被自动清除。 |
| vucreate | 创建任务。 |
| vudestroy | 停止任务。 |
| vurun | 运行任务。 |
| vuset | 任务运行参数配置，例如并行数和日志配置。 |
| vustatus | 查看任务执行状态。 |


3. 加载数据，依次执行下列命令。
```
dbset db mysql
dbset bm tpc-h
diset connection mysql_host 127.0.0.1
diset tpch mysql_tpch_user root
diset tpch mysql_tpch_pass 123456
diset tpch mysql_tpch_storage_engine innodb
diset tpch mysql_tpch_dbase mysql_tpch
diset tpch mysql_scale_fact 1
diset tpch mysql_num_tpch_threads 30
```

| 命令 | 说明 |
| --- | --- |
| dbset db mysql | 配置数据库的类型。 |
| dbset bm tpc\-h | 配置测试模型。 |
| diset connection mysql\_host 127.0.0.1 | 配置数据库的服务地址，默认是127.0.0.1。 |
| diset tpch mysql\_tpch\_user root | 配置数据库的管理用户，默认为root。 |
| diset tpch mysql\_tpch\_pass 123456 | 配置数据库管理用户的密码。 |
| diset tpch mysql\_tpch\_storage\_engine innodb | 默认使用数据库引擎MyISAM。 |
| diset tpch mysql\_tpch\_dbase mysql\_tpch | 配置数据库管理用户的库。 |
| diset tpch mysql\_scale\_fact 1 | 配置数据量，默认为1。 |
| diset tpch mysql\_num\_tpch\_threads 30 | 配置并发数。 |


  a. 查看配置信息。
    1 print dict

    mysql_tpch_user、mysql_tpch_pass、mysql_tpch_dbase为默认新增的测试库信息，请确保执行前数据库服务器上无相同名称的用户以及数据库，如已存在，请先删除或通过diset命令修改相关参数。

    1 buildschema

    返回字段“ALL VIRTUAL USERS COMPLETE”，表示数据导入成功。

  b. 执行以下命令。
    1 2 vustatus vudestroy

4. 执行测试。
```
vuset vu 5
vuset showoutput 1
vuset logtotemp 1
vuset unique 1
print vuconf
```

| 命令 | 含义 |
| --- | --- |
| vuset vu 5 | 配置并发执行任务数。 |
| vuset showoutput 1 | 开启日志。 |
| vuset logtotemp 1 | 开启日志自动保存至“/tmp”。 |
| vuset unique 1 | 配置日志唯一性，即不覆盖。 |
| print vuconf | 查看任务配置。 |


  a. 加载配置。
    1 loadscript

  b. 创建任务。
    1 vucreate

  c. 运行任务。
    1 vurun

    返回SUCCESS，取执行耗时作为测试指标。
