ablog

不器用で落着きのない技術者のメモ

MySQL をソースコードからビルドする

準備

sudo yum install git
sudo yum install cmake
sudo yum install gcc
sudo yum install gcc-c++
sudo yum install ncurses-devel

mysql-build のインストール

git clone git://github.com/kamipo/mysql-build.git ~/mysql-build
export PATH="$HOME/mysql-build/bin:$PATH"

MySQL をビルドする

mkdir -p ~/opt/mysql
mysql-build -v 5.7.10 ~/opt/mysql/mysql-5.7.10

確認する

cd ~/opt/mysql/mysql-5.7.10
./bin/mysqld --initialize-insecure --basedir=.
./bin/mysqld_safe &
  • SQL を実行する
$ ./bin/mysql -u root -e 'SELECT @@version'
+-----------+
| @@version |
+-----------+
| 5.7.10    |
+-----------+

補足

collect2: ld terminated with signal 9 [Killed]

とエラーが出たので、

Your virtual machine does not have enough memory to perform the linking phase. Linking is typical the most memory intensive part of a build since it's where all the object code comes together and is operated on as a whole.

If you can allocate more RAM to the VM then do that. Alternatively you could increase the amount of swap space. I am not that familiar with VMs but I imagine the virtual hard drive you set-up will have a swap partition. If you can make that bigger or allocate a second swap partition that would help.

Increasing the RAM, if only for the duration of your build, is the easiest thing to do though.

gcc - Why is the linker terminating on me? when i build CLang - Stack Overflow

を参考にメモリサイズの大きいマシンでビルドすると成功した。

MySQLのソースコードを入手する

補足

最新バージョン以外は以下からダウンロードできる。

参考

Webエンジニアのための データベース技術[実践]入門 (Software Design plus)

Webエンジニアのための データベース技術[実践]入門 (Software Design plus)

P.168-169