GDB 調試 Mysql 實戰(一)源碼編譯安裝

下載源碼

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

編譯安裝

安裝依賴html

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

須要注意的一點,須要指定 boost 路徑,會 cmake 的時候自動下載mysql

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

最後程序安裝到了/usr/local/mysql目錄linux

建立專用用戶

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

初始化數據庫c++

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

鏈接數據庫git

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

原來是由於配置文件裏面沒有置頂客戶端的 socket 文件github

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

增長sql

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

再次鏈接就 ok 了。數據庫

修改默認密碼

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

導入測試數據

/usr/local/mysql/bin/mysql -uroot -p123456 test < article_rank.sql
https://www.linuxidc.com/Linu...
https://www.cnblogs.com/debmz...
相關文章
相關標籤/搜索