Category: MySQL

MySQL Performance Testing with mysqlslap

MySQL comes with its own stress-testing tool, mysqlslap.

Here is an example testing 500 concurrent connections and running the test 10 times:
mysqlslap -a -c 500 -i 10 -uroot -p123456
The results are as follows:

How to Install Alibaba AliSQL

Install dependency packages yum install -y centos-release-scl devtoolset-4-gcc-c++ devtoolset-4-gcc cmake openssl-devel bison git gmock ncurses ncurses-* autoconf
Create account groupadd mysql && useradd -r -g mysq …

MySQL COUNT Query Group by Date

Sometimes queried data needs to be detailed down to daily statistics. The statement is as follows and can be modified according to your situation:

Taking the user table as an example, query daily signup counts and group by day. The signupTime field is a date in the format “2019-09-05 00:38:17”:

Query statement: select DATE_FORMAT(signup …

go-mysql-elasticsearch: Syncing MySQL Data to Elasticsearch

Project GitHub address: https://github.com/siddontang/go-mysql-elasticsearch The basic principle of go-mysql-elasticsearch is: when the program starts for the first time, it first uses the mysqldump tool to perform a full sync of the source MySQL database, then writes data to ES through the elasticsearch client; then it implements a mysql client that connects to the source MySQL as a slave. The source MySQL as master will synchronize all data update operations to the slave via binlog events. By parsing the binlog events, you can obtain the updated content of the data, and then write it to ES.

MySQL Table Synchronization Trigger

Trigger Synchronization Between Two Tables in the Same Database:

#Insert
delimiter ||
DROP TRIGGER IF EXISTS t_afterinsert_on_tab1 ||
CREATE TRIGGER t_afterinsert_on_tab1
AFTER INSERT ON test1
FOR EACH ROW
BEGIN
insert into test2 …

MySQL Import Error: Invalid Default Value Fix

Due to a database upgrade, an error occurs when importing an SQL file from a lower version database into a higher version database:

The reason is the database SQL mode: mysql> show variables like 'sql_mode'; #Check current mode
| sql_mode | ONLY_FULL_GROUP_BY,STRICT_T …