标签 mysql 下的文章

安装

$ sudo apt install mysql-server

查看默认账号密码

$ sudo cat /etc/mysql/debian.cnf
# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host     = localhost
user     = debian-sys-maint
password = JRvfA0JiQGk5qhnz
socket   = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host     = localhost
user     = debian-sys-maint
password = JRvfA0JiQGk5qhnz
socket   = /var/run/mysqld/mysqld.sock

修改密码

$ mysql -udebian-sys-maint -pJRvfA0JiQGk5qhnz
mysql>USE mysql;

// mysql 5.7
mysql>UPDATE user SET plugin='mysql_native_password' WHERE User='root';
mysql>update mysql.user set authentication_string=password('xxx') where User='root' and Host='localhost';
// mysql 8.0
mysql>ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'xxx';

mysql>flush privileges;
mysql>exit;

测试命令

sysbench --test=oltp_read_write --tables=10 --table-size=1000000 --report-interval=10 --time=3600 --threads=50 --db-driver=mysql --mysql-socket=/tmp/mysql.sock --mysql-user=root --mysql-password='xxxx' --mysql-db=sbtest run

8.0.21 测试结果

SQL statistics:
    queries performed:
        read:                            15339058
        write:                           4382588
        other:                           2191294
        total:                           21912940
    transactions:                        1095647 (304.28 per sec.)
    queries:                             21912940 (6085.57 per sec.)
    ignored errors:                      0      (0.00 per sec.)
    reconnects:                          0      (0.00 per sec.)

General statistics:
    total time:                          3600.8045s
    total number of events:              1095647

Latency (ms):
         min:                                    2.74
         avg:                                  164.30
         max:                                 5033.06
         95th percentile:                      707.07
         sum:                            180014353.79

Threads fairness:
    events (avg/stddev):           21912.9400/80.08
    execution time (avg/stddev):   3600.2871/0.22

8.0.23 测试结果

SQL statistics:
    queries performed:
        read:                            2969064
        write:                           848304
        other:                           424152
        total:                           4241520
    transactions:                        212076 (58.89 per sec.)
    queries:                             4241520 (1177.79 per sec.)
    ignored errors:                      0      (0.00 per sec.)
    reconnects:                          0      (0.00 per sec.)

General statistics:
    total time:                          3601.2587s
    total number of events:              212076

Latency (ms):
         min:                                    3.57
         avg:                                  848.89
         max:                                 6098.82
         95th percentile:                     1973.38
         sum:                            180029441.14

Threads fairness:
    events (avg/stddev):           4241.5200/32.35
    execution time (avg/stddev):   3600.5888/0.34

清空日志

mysql> reset master;

查询是否开启了binlog

$mysql -uroot -p
mysql>use mysql;
mysql>
mysql> show variables like 'log_bin';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_bin       | ON    |
+---------------+-------+
1 row in set (0.01 sec)

阅读剩余部分