生成目录
// 生成编译后安装目录及数据目录
mkdir -p build_out/data
编译
cmake . -DWITH_DEBUG=1 \
-DCMAKE_INSTALL_PREFIX=build_out \
-DMYSQL_DATADIR=bui
ld_out/data
make && make install
初始化 mysql 数据库
cd build_out
➜ build_out git:(5.7) ✗ bin/mysql_install_db
2021-06-17 17:31:11 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2021-06-17 17:31:11 [ERROR] The data directory needs to be specified.
➜ build_out git:(5.7) ✗ mysqld --initialize
2021-06-17T09:31:12.953002Z 0 [System] [MY-013169] [Server] /usr/local/Cellar/mysql/8.0.21_1/bin/mysqld (mysqld 8.0.21) initializing of server in progress as process 61881
2021-06-17T09:31:12.956680Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
2021-06-17T09:31:12.956688Z 0 [ERROR] [MY-013236] [Server] The designated data directory /usr/local/var/mysql/ is unusable. You can remove all files that the server added to it.
2021-06-17T09:31:12.956739Z 0 [ERROR] [MY-010119] [Server] Aborting
2021-06-17T09:31:12.956911Z 0 [System] [MY-010910] [Server] /usr/local/Cellar/mysql/8.0.21_1/bin/mysqld: Shutdown complete (mysqld 8.0.21) Homebrew.