---
title: 加载数据
description: 向数据库导入测试数据的操作步骤以测试MySQL数据库为例进行描述，MariaDB、Percona的测试步骤与MySQL相同。
url: "https://www.hikunpeng.com/document/detail/zh/kunpengdbs/testguide/tstg/kunpengsysbench_02_0009.html"
---

# 加载数据

向数据库导入测试数据的操作步骤以测试MySQL数据库为例进行描述，MariaDB、Percona的测试步骤与MySQL相同。

1. 登录MySQL数据库。
  1 /usr/local/mysql/bin/mysql -uroot -p'********' -S /data/mysql/run/mysql.sock

2. 创建数据库sysbench。
  1 2 3 4 create database sysbench; show databases; use sysbench; show tables;

3. 登录Sysbench工具客户端，向数据库导入测试数据，数据量为100张表*100万行数据（100*1000000）。
- 命令字段含义请参见  表1
、  表2
、  表3
、  表4
和  表5
。
- 请根据实际情况替换以下参数的值：--mysql-host、--mysql-port、--mysql-password、--oltp-table-size、--oltp-tables-count。


  - 如果使用的是Sysbench 0.5，请使用如下命令：
    1 /home/sysbench-0.5/sysbench/sysbench --db-driver=mysql --test=/home/sysbench-0.5/sysbench/tests/db/parallel_prepare.lua --oltp-test-mode=complex --mysql-host=192.168.***.*** --mysql-port=3306 --mysql-db=sysbench --mysql-user=root --mysql-password=******** --max-time=7200 --max-requests=0 --mysql-table-engine=innodb --oltp-table-size=1000000 --oltp-tables-count=100 --rand-type=special --rand-spec-pct=100 --num-threads=60 prepare

  - 如果使用的是Sysbench 1.0，请使用如下命令：
    1 /home/sysbench-1.0/src/sysbench --db-driver=mysql --mysql-host=192.168.***.*** --mysql-port=3306 --mysql-user=root --mysql-password=******** --mysql-db=sysbench --table_size=1000000 --tables=100 --time=180 --threads=96 --report-interval=10 oltp_read_write prepare
