登录
首页 >  数据库 >  MySQL

GDB 调试 Mysql 实战(一)源码编译安装

来源:SegmentFault

时间:2023-02-24 17:41:22 286浏览 收藏

数据库小白一枚,正在不断学习积累知识,现将学习到的知识记录一下,也是将我的所得分享给大家!而今天这篇文章《GDB 调试 Mysql 实战(一)源码编译安装》带大家来了解一下GDB 调试 Mysql 实战(一)源码编译安装,希望对大家的知识积累有所帮助,从而弥补自己的不足,助力实战开发!

下载源码

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

编译安装

安装依赖

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

需要注意的一点,需要指定 boost 路径,会 cmake 的时候自动下载

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

最后程序安装到了

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

初始化数据库

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

连接数据库

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

原来是因为配置文件里面没有置顶客户端的 socket 文件

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

增加

[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 
https://www.linuxidc.com/Linu...
https://www.cnblogs.com/debmz...

本篇关于《GDB 调试 Mysql 实战(一)源码编译安装》的介绍就到此结束啦,但是学无止境,想要了解学习更多关于数据库的相关知识,请关注golang学习网公众号!

声明:本文转载于:SegmentFault 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>