0.下载源码略(最好下载带boost那个)
1.安装工具:sudo apt-get install gcc-4.8, g++4.8,cpp-4.8, cmake
2.安装依赖包:sudo apt-get install openssl libssl-dev libncurses5-dev bison
3.添加用户: groupadd mysql; useradd -r -g mysql -s /bin/false mysql
4.cd mysql-VERSION; mkdir bld; cd bld
5. cmake .. -DCMAKE_BUILD_TYPE=Debug -DWITH_BOOST=../boost -DCMAKE_INSTALL_PREFIX=/opt/mysql
(我需要打开debug调试功能,你也许不需要就去掉前面的Debug, ps 可以用cmake .. -LAH查看所有支持选项)
注意,有时候装了依赖库后还会莫名报错,只要 rm CMakeCache.txt后重新cmake就能过去
6. make -j 4
7. make install (/opt/mysql要先解决好权限)
简单配置文件(可以放在/etc/my.cnf或者$HOME/.my.cnf)如下:
[client]
socket = /tmp/mysql.sock
[mysqld]
user = mysql
socket = /tmp/mysql.sock
basedir = /opt/mysql
datadir = /home/mysql/data
log-error = error.log
server-id = 3306
按以上建立目录/home/mysql/data
$/opt/mysql/bin/mysqld --initialize-insecure
$ /opt/mysql/bin/mysqld_safe &
客户端连接: mysql -u root -h localhost -p
关闭数据库: mysqladmin -u root -h localhost -p shutdown