1,下载软件
https://downloads.mysql.com/archives/community/
2,开始安装mysql
groupadd mysql
useradd mysql -g mysql -s /sbin/nologin -M
3, 安装软件包
yum -y install openssl openssl-devel
4,编译安装
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql5.7/
-DMYSQL_DATADIR=/dbfiles/mysql_home/mysql3308/data/
-DSYSCONFDIR=/root/sf/mysql3312/
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_ARCHIVE_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1
-DWITH_FEDERATED_STORAGE_ENGINE=1
-DWITH_PARTITION_STORAGE_ENGINE=1
-DMYSQL_UNIX_ADDR=/root/sf/mysql3312/mysql3312.sock
-DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1
-DEXTRA_CHARSETS=all
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_USER=mysql -DWITH_BINLOG_PREALLOC=ON -DWITH_BOOST=/root/sf/mysql-5.7.26/boost/boost_1_59_0 -DWITH_DEBUG=1
Make
Make install
5,配置/etc/my.cnf
6,初始化mysqlmysqld --initialize
7,启动mysql mysqld
8,使用gdb启动MySQL
attach pid
(gdb) attach 2075
设置断点
(gdb) b trace_tmp_table
Breakpoint 1 at 0x15bed7b: file /dbfiles/soft/mysql-5.7.31/sql/sql_tmp_table.cc, line 2307.
客户端连接(阻塞中)
[root@localhost ~]# /dbfiles/scripts/mysql_login.sh
mysql: [Warning] Using a password on the command line interface can be insecure.
打印 backtrace
(gdb) bt
#0 0x00007f0d839d3bed in poll () from /lib64/libc.so.6
#1 0x00000000016456a9 in Mysqld_socket_listener::listen_for_connection_event (this=0x5516470)
at /dbfiles/soft/mysql-5.7.31/sql/conn_handler/socket_connection.cc:859
#2 0x0000000000e87006 in Connection_acceptor<Mysqld_socket_listener>::connection_event_loop (this=0x55117e0)
at /dbfiles/soft/mysql-5.7.31/sql/conn_handler/connection_acceptor.h:73
#3 0x0000000000e7e90e in mysqld_main (argc=41, argv=0x304faf8) at /dbfiles/soft/mysql-5.7.31/sql/mysqld.cc:5132
#4 0x0000000000e758fd in main (argc=1, argv=0x7ffd7ca9e348) at /dbfiles/soft/mysql-5.7.31/sql/main.cc:32
(gdb)
因为主进程在 poll 一直在等待客户端连接请求。
执行 continue
(gdb) c
Continuing.
客户端执行查询
mysql> use test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> SET optimizer_trace='enabled=on';
Query OK, 0 rows affected (0.00 sec)
mysql> select aid,sum(pv) as num from article_rank force index(idx_day_aid_pv) where day>20181223 group by aid order by num desc LIMIT 10;
查看断点处信息
(gdb) p table->s->reclength
$1 = 20
(gdb) p table->s->fields
$2 = 2
(gdb) p (*(table->field+0))->field_name
$3 = 0x7eff94010b0c "aid"
(gdb) p (*(table->field+1))->field_name
$4 = 0x7eff94007518 "num"
(gdb) p (*(table->field+0))->row_pack_length()
$5 = 4
(gdb) p (*(table->field+1))->row_pack_length()
$6 = 15
(gdb) p (*(table->field+0))->type()
$7 = MYSQL_TYPE_LONG
(gdb) p (*(table->field+1))->type()
$8 = MYSQL_TYPE_NEWDECIMAL
(gdb)