源码下载
地址:https://www.percona.com/downloads/Percona-Server-5.7/
下载版本:percona-server-5.7.21-21
解压下载后的tar.gz文件
构建Xcode工程,并编译
1. 构建Xcode工程
# 进入percona-server-5.7.21-21 并创建work文件夹,然后执行如下命令, 注意根据实际情况修改对应路径
cmake . -G "Xcode" -DWITH_DEBUG=1 -DWITH_TOKUDB_STORAGE_ENGINE=OFF -DWITHOUT_TOKUDB_STORAGE_ENGINE=ON -DCMAKE_INSTALL_PREFIX=./work -DDOWNLOAD_BOOST=1 -DWITH_BOOST=./boost_1_59_0
2. 编译
使用xcode打开percona-server-5.7.21-21,选择自动创建scheme
点击左上角的,选择mysqld
然后点击三角形编译
copy生成的可执行文件到work对应路径
cd work ; mkdir {bin,share,scripts,data}
cp sql/Debug/mysqld work/bin/
cp client/Debug/mysql* work/bin/
cp extra/Debug/my_print_defaults work/bin/
cp -r sql/share/* work/share/
cp -r scripts/* work/scripts/
chmod +x work/scripts/*
cp scripts/*.sql work/share/
cp support-files/*.cnf work/share/
初始化数据库
# 事先创建mysql用户
mysqld --initialize-insecure --user=mysql
xcode运行调试mysql
编辑schema设置参数和环境变量(注意根据实际情况设置路径)
参考连接
https://ruiaylin.github.io/2015/06/03/mysql%20source%20code%20debug%20xcode/