mac上编译安装mysql5.6
主要是了解mysql源码,安装cmake和gcc源码编译,发现依赖包太多,即使安装上相关包,Gcc还是无法安装,官方也不建议源码编译安装,经查资源 发现homebrew
homebrew官网:https://docs.brew.sh/Installation.html 安装简单 步骤如下:
1.mkdir homebrew && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 128 0 128 0 0 106 0 --:--:-- 0:00:01 --:--:-- 106
100 1091k 100 1091k 0 0 158k 0 0:00:06 0:00:06 --:--:-- 256k
==> Homebrew has enabled anonymous aggregate user behaviour analytics.
Read the analytics documentation (and how to opt-out) here:
https://docs.brew.sh/Analytics.html
==> Tapping homebrew/core
Cloning into '/Users/homebrew/Library/Taps/homebrew/homebrew-core'...
remote: Counting objects: 4672, done.
remote: Compressing objects: 100% (4414/4414), done.
remote: Total 4672 (delta 62), reused 1111 (delta 46), pack-reused 0
Receiving objects: 100% (4672/4672), 3.81 MiB | 1.23 MiB/s, done.
Resolving deltas: 100% (62/62), done.
Tapped 4444 formulae (4,719 files, 12.0MB)
Error: Xcode alone is not sufficient on Sierra.
Install the Command Line Tools:
xcode-select --install
因为我之前装过x-code 所以有此工具
2. xcode-select --install gcc
3. ./brew install gcc
Updating Homebrew...
==> Installing dependencies for gcc: gmp, mpfr, libmpc, isl
==> Installing gcc dependency: gmp
==> Downloading https://homebrew.bintray.com/bottles/gmp-6.1.2_1.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring gmp-6.1.2_1.sierra.bottle.tar.gz
🍺 /Users/homebrew/Cellar/gmp/6.1.2_1: 18 files, 3.1MB
==> Installing gcc dependency: mpfr
==> Downloading https://homebrew.bintray.com/bottles/mpfr-3.1.6.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring mpfr-3.1.6.sierra.bottle.tar.gz
🍺 /Users/homebrew/Cellar/mpfr/3.1.6: 26 files, 3.6MB
==> Installing gcc dependency: libmpc
==> Downloading https://homebrew.bintray.com/bottles/libmpc-1.0.3_1.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring libmpc-1.0.3_1.sierra.bottle.tar.gz
🍺 /Users/homebrew/Cellar/libmpc/1.0.3_1: 12 files, 345.0KB
==> Installing gcc dependency: isl
==> Downloading https://homebrew.bintray.com/bottles/isl-0.18.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring isl-0.18.sierra.bottle.tar.gz
🍺 /Users/homebrew/Cellar/isl/0.18: 80 files, 3.8MB
==> Installing gcc
==> Downloading https://ftp.gnu.org/gnu/gcc/gcc-7.2.0/gcc-7.2.0.tar.xz
######################################################################## 100.0%
==> Downloading https://raw.githubusercontent.com/Homebrew/formula-patches/e9e0ee09389a54cc4c8fe1c24eb
curl: (28) Operation timed out after 300151 milliseconds with 0 out of 0 bytes received
Error: Failed to download resource "gcc--patch"
Download failed: https://raw.githubusercontent.com/Homebrew/formula-patches/e9e0ee09389a54cc4c8fe1c24ebca3cd765ed0ba/gcc/6.1.0-jit.patch
4. ./brew install cmake
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> New Formulae
rsync-time-backup
==> Downloading https://homebrew.bintray.com/bottles/cmake-3.10.1.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring cmake-3.10.1.sierra.bottle.tar.gz
==> Caveats
Emacs Lisp files have been installed to:
/Users/homebrew/share/emacs/site-lisp/cmake
==> Summary
🍺 /Users/homebrew/Cellar/cmake/3.10.1: 2,334 files, 32.4MB
5../brew install ncurses-devel
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
gpsbabel metabase
Error: No available formula with the name "ncurses-devel"
==> Searching for a previously deleted formula...
Warning: homebrew/core is shallow clone. To get complete history run:
git -C "$(brew --repo homebrew/core)" fetch --unshallow
Error: No previously deleted formula found.
==> Searching for similarly named formulae...
==> Searching local taps...
Error: No similarly named formulae found.
==> Searching taps...
==> Searching taps on GitHub...
Error: No formulae found in taps.
6.git -C "$(brew --repo homebrew/core)" fetch --unshallow
-bash: brew: command not found
remote: Counting objects: 108, done.
remote: Compressing objects: 100% (46/46), done.
Receiving objects: 100% (108/108), 17.39 KiB | 0 bytes/s, done.
remote: Total 108 (delta 80), reused 90 (delta 62), pack-reused 0
Resolving deltas: 100% (80/80), completed with 23 local objects.
From https://github.com/Homebrew/brew
0cbe1f3a0..67c440263 master -> origin/master
* [new branch] revert-3536-prune_default_formula_only_if_installed -> origin/revert-3536-prune_default_formula_only_if_installed
先下载mysql的源码包 解压后 编译
~/homebrew/bin/cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/var/lib/mysql/data -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR==/var/lib/mysql/mysql.sock -DMYSQL_USER=xep -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
make && make install
在mac上装了5.6.36-82.0 报错 ld: library not found for –lrt 官方bug上有信息 所以又重新编译的5.6.20-68.0 成功安装