mysqlmysqlslap压力测试_MySQL
bitsCN.com
mysqlslap
简介
mysql 压力测试工具
选项
选项 简写 说明 --auto-generate-sql -a 自动生成MySQL测试语句 --auto-generate-sql-add-autoincrement 添加AUTO_INCREMENT字段 --auto-generate-sql-execute-number=# 查询的个数 --auto-generate-sql-guid-primary 添加GUID字段 --auto-generate-sql-load-type=name mixed:混合、update:更新、write:写入、key:读主键、read:查询 --auto-generate-sql-secondary-indexes=# 设置索引字段个数 --auto-generate-sql-unique-query-number=# 生成N条不同的query sql语句 --auto-generate-sql-unique-write-number=# 生成N条不同的write sql语句 --auto-generate-sql-write-number=# 每个线程write sql语句数量 --commit=# 设置每多少条sql语句提交一次 --compress -C 启用压缩协议 --concurrency=# -c 客户端数量(并发量) --create=name 测试的SQL语句或文件 --create-schema=name 测试的数据名 --csv=name 生产CSV格式数据文件 --debug -# 写调试日志(windows不可用) 如:mysqlslap -a -#"d:t:o,c:/debug.txt" --debug-check 测试后打印调试信息(windows不可用) --debug-info -T 打印内存和CPU的相关信息 --default-auth=plugin 验证插件 --delimiter=str -F 语句分隔符默认是 ; --detach=# 执行N条语句后断开重连 --enable-cleartext-plugin 启用明文身份验证插件 --engine=engine_name -e 测试引擎 如:mysqlslap -e"myisam"或-e"myisam,innodb" --help 帮助信息 --host=host_name -h 数据库host --iterations=# -i 迭代运行次数 --login-path=name 登陆配置文件 详见 --no-drop 测试后不删除schema --number-char-cols=# -x 设置VARCHAR类型字段数量 --number-int-cols=# -y 设置INT类型字段数量 --number-of-queries=# 每个客户端运行sql语句数量 受 --only-print 仅显示将被运行的SQL语句--delimiter选项影响 --password=password -p 数据库密码 --pipe 启用管道 --plugin-dir=path 插件目录 --port=port_num -P 数据库端口 --post-query=value 测试后执行的SQL语句 --post-system=str 测试后执行的系统语句 --pre-query=value 测试前执行的SQL语句 --pre-system=str 测试前执行的系统语句 --protocol=type 链接协议 tcp, socket, pipe --query=value -q 测试的SQL语句 如:mysqlslap -q"SELECT * FROM t1" --secure-auth 不要发送密码到服务器 --silent -s 不显示测试(静音测试) --socket=path -S 连接服务器的socket --ssl-ca=file_name --ssl-capath=dir_name --ssl-cert=file_name --ssl-cipher=cipher_list --ssl-crl=file_name --ssl-crlpath=dir_name --ssl-key=file_name --ssl-verify-server-cert --user=user_name -u 数据库用户名 --verbose -v 输出更多的信息 --version -V 版本信息例子
远程测试如:mysqlslap -a -h"192.168.1.139" -P3306 -p指定sql语句 如:mysqlslap --create-schema=test -q"select * from user"自动测试 如:mysqlslap -a显示测试sql语句 如:mysqlslap -a --only-print
报表
我们测试本地数据库引擎性能
mysqlslap -a -e"myisam,innodb" --csv="c:/a.csv"
c:/a.csv文件
我们转换成图表形式
可以看出 myisam,innodb 混合测试时myisam性能更好些 读写时间更少
常用选项
Windows默认配置文件读取顺序:C:/WINDOWS/my.ini
C:/WINDOWS/my.cnf
C:/my.ini
C:/my.cnf
F:/mysql/5.6.16/my.ini
F:/mysql/5.6.16/my.cnf
-h 数据库host
-u 数据库用户名
-p 数据库密码
-P 数据库端口
--create-schema=name 测试的数据名
--create=name 测试的SQL语句或文件
--no-drop 测试后不删除schema
--only-print 仅显示将被运行的SQL语句
-c 客户端数量(并发量) 如:mysqlslap -c"10"或-c"10,100,1000"
-e 测试引擎 如:mysqlslap -e"myisam"或-e"myisam,innodb"
--number-of-queries=# SQL语句执行总次数 如:mysqlslap -a --number-of-queries="10"
-q 测试的SQL语句 如:mysqlslap -q"SELECT * FROM t1"
-i 迭代运行次数 如:mysqlslap -a -i"3"
-T 显示内存和CPU信息并退出 如:mysqlslap -a -T
-F SQL语句分隔符
-s 不输出无回显运行
--csv[=name] 生产CSV格式数据文件
--commit=# 设置每多少条sql语句提交一次
--detach=# 设置每多少条sql语句重连服务器一次
-a,--auto-generate-sql 自动生成MySQL测试语句
--auto-generate-sql-add-autoincrement 添加AUTO_INCREMENT字段
--auto-generate-sql-execute-number=# 查询的个数
--auto-generate-sql-guid-primary 添加GUID字段
--auto-generate-sql-load-type=name mixed:混合、update:更新、write:写入、key:读主键、read:查询
--auto-generate-sql-secondary-indexes=# 设置索引字段个数
--auto-generate-sql-unique-query-number=# 生成N条不同的query sql语句
--auto-generate-sql-unique-write-number=# 生成N条不同的write sql语句
--auto-generate-sql-write-number=# 每个线程write sql语句数量
-x, --number-char-cols=name 设置VARCHAR类型字段数量 默认1
-y, --number-int-cols=name 设置INT 类型字段数量默认1
bitsCN.com

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

Laravel is a PHP framework for easy building of web applications. It provides a range of powerful features including: Installation: Install the Laravel CLI globally with Composer and create applications in the project directory. Routing: Define the relationship between the URL and the handler in routes/web.php. View: Create a view in resources/views to render the application's interface. Database Integration: Provides out-of-the-box integration with databases such as MySQL and uses migration to create and modify tables. Model and Controller: The model represents the database entity and the controller processes HTTP requests.

The process of starting MySQL in Docker consists of the following steps: Pull the MySQL image to create and start the container, set the root user password, and map the port verification connection Create the database and the user grants all permissions to the database

I encountered a tricky problem when developing a small application: the need to quickly integrate a lightweight database operation library. After trying multiple libraries, I found that they either have too much functionality or are not very compatible. Eventually, I found minii/db, a simplified version based on Yii2 that solved my problem perfectly.

The key to installing MySQL elegantly is to add the official MySQL repository. The specific steps are as follows: Download the MySQL official GPG key to prevent phishing attacks. Add MySQL repository file: rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm Update yum repository cache: yum update installation MySQL: yum install mysql-server startup MySQL service: systemctl start mysqld set up booting

Installing MySQL on CentOS involves the following steps: Adding the appropriate MySQL yum source. Execute the yum install mysql-server command to install the MySQL server. Use the mysql_secure_installation command to make security settings, such as setting the root user password. Customize the MySQL configuration file as needed. Tune MySQL parameters and optimize databases for performance.

Article summary: This article provides detailed step-by-step instructions to guide readers on how to easily install the Laravel framework. Laravel is a powerful PHP framework that speeds up the development process of web applications. This tutorial covers the installation process from system requirements to configuring databases and setting up routing. By following these steps, readers can quickly and efficiently lay a solid foundation for their Laravel project.

MySQL and phpMyAdmin are powerful database management tools. 1) MySQL is used to create databases and tables, and to execute DML and SQL queries. 2) phpMyAdmin provides an intuitive interface for database management, table structure management, data operations and user permission management.
