GDB debugging Mysql source compilation and installation

Download source code

git clone https://github.com/mysql/mysql-server.git
cd mysql-server
git checkout 5.7

Compilation and installation

Installation dependency

yum install -y cmake make gcc gcc-c++ ncurses-devel bison gdb

Note that you need to specify the boost path, which will be downloaded automatically when cmake

cd BUILD; 
cmake .. -DDOWNLOAD_BOOST=1 -DWITH_BOOST=<directory> -DWITH_DEBUG=1 -DWITH_UNIT_TESTS=off
make 
make install

Finally, the program is installed in / usr/local/mysql directory

Create a dedicated user

groupadd mysql
useradd -s /sbin/nologin -M -g mysql mysql

Initialize database

cd /usr/local/mysql/
bin/mysqld --defaults-file=/etc/my.cnf --initialize --user=mysql

2019-02-01T07:45:58.147032Z 1 [Note] A temporary password is generated for root@localhost: jss<swtX.8og

Connect to database

[root@bogon bin]# ./mysql -h localhost -uroot
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

The reason is that there is no socket file of the top client in the configuration file

cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd

[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

increase

[client]
default-character-set=utf8
socket=/var/lib/mysql/mysql.sock
[mysql]
default-character-set=utf8
socket=/var/lib/mysql/mysql.sock

Just connect again.

Change default password

SET PASSWORD = PASSWORD('123456');
ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
flush privileges;

Import test data

/usr/local/mysql/bin/mysql -uroot -p123456 test < article_rank.sql

https://www.linuxidc.com/Linu...
https://www.cnblogs.com/debmz...

Tags: MySQL socket MariaDB git

Posted on Wed, 04 Dec 2019 11:32:44 -0500 by philippe2