您好,欢迎访问一九零五行业门户网

mysql 5.5以上编译安装_MySQL

bitscn.com
mysql 5.5以上编译安装
mysql 5.5 以上的版本 社区版采用的是cmake 编译安装,不再采用之前gnu autotools 工具的 ./configure make make install安装了。
1. 系统环境
无论是centos还是debian ,都需要安装一些基础软件,例如gcc等:
gcc* gcc-c++* autoconf* automake* zlib* libxml* ncurses-devel* libgcrypt* libtool*
yum -y install
apt-get install
2.安装
1 下载软件
wget http://www.cmake.org/files/v2.8/cmake-2.8.10.tar.gz
wget http://gd.tuwien.ac.at/db/mysql/downloads/mysql-5.6/mysql-5.6.12.tar.gz
准备
1
cd /usr/local
2
mkdir mysql
3
cd mysql
4
mkdir data
5
groupadd mysql
6
useradd –r –g mysql mysql
7
mkdir /usr/local/mysql/data  (数据文件夹)
8
chown –r mysql.mysql /usr/local/mysql/data
2 安装
cmake 的编译参数通过这里查看
01
tar xzvf cmake-2.8.10.tar.gz
02
cd cmake-2.8.10
03
./bootstrap
04
make
05
make install
06
cd mysql-5.6.12
07
cmake . -dcmake_install_prefix=/usr/local/mysql /
08
-dmysql_unix_addr=/usr/local/mysql/mysql.sock /
09
-ddefault_charset=utf8 /
10
-ddefault_collation=utf8_general_ci /
11
-dwith_extra_charsets:string=utf8,gbk /
12
-dwith_innobase_storage_engine=1/
13
-dwith_archive_storage_engine=1/
14
-dwith_blackhole_storage_engine=1/
15
-dwith_perfschema_storage_engine=1/
16
-dwith_readline=yes /
17
-denabled_local_infile=1 /
18
-dmysql_datadir=/usr/local/mysql/data /
19
-dmysql_tcp_port=3306
1
make
2
make install
3. 更改文件夹权限和初始化数据库 
1
cd /usr/local/mysql
2
chown –r mysql .
3
chgrp –r mysql .
复制配置文件,启动 
01
cp support-files/my-medium.cnf /etc/my.cnf
02
#初始化 table
03
chmod 755 scripts/mysql_install_db
04
 scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/       #此处指定用user用户运行
05
chown –r root .
06
chown –r mysql data
07
08
nohup ./bin/mysqld_safe --defaults-file=/etc/my.cnf &             #后台运行
09
#开机启动
10
cp support-files/mysql.server /etc/init.d/mysql.server   # 系统服务
1
chkconfig --add mysql.server       #开机启动
 这里启动的时候会报一警告:
[warning] timestamp with implicit default value is deprecated. please use --explicit_defaults_for_timestamp server option (see documentation for more details).
请在 my.cnf 文件里配置 explicit_defaults_for_timestamp=true
后记:
1.mysql 编译时参数 autotools 和 cmake 的一些对比
斜体是较常用的(以下内容摘自mysql官方网站)http://forge.mysql.com/wiki/autotools_to_cmake_transition_guide 
参数 configure 选项 cmake 选项 cmake 说明 
主安装目录 --prefix=/usr -dcmake_install_prefix=/usr 
mysqld 目录 --libexecdir=/usr/sbin -dinstall_sbindir=sbin 该目录相对--prefix,相当于/usr/sbin,不要加前缀(以下标“同上”的一样) 
数据目录 --localstatedir=/var/lib/mysql -dmysql_datadir=/var/lib/mysql   
配置文件my.cnf 目录 --sysconfdir=/etc/mysql -dsysconfdir=/etc/mysql   
插件目录 --with-plugindir=/usr/lib64/mysql/plugin -dinstall_plugindir=lib64/mysql/plugin 同上 
man page 目录 --mandir=/usr/share/man -dinstall_mandir=share/mysql 同上 
共享数据目录 --sharedstatedir=/usr/share/mysql -dinstall_sharedir=share aclocal/mysql.m4 安装目录 
库安装目录 --libdir=/usr/lib64/mysql -dinstall_libdir=lib64/mysql 同上 
header 安装目录 --includedir=/usr/include/mysql -dinstall_includedir=include/mysql 同上 
信息文档目录 --infodir=/usr/share/info -dinstall_infodir=share/info 同上 
存储引擎也是做为插件安装的,configure 方式接受 --with-plugins 参数指定参数方式以逗号分隔或组名形式安装插件,但在 cmake 中各存储引擎是以参数形式单独配置的,以下几个较常用: 
-dwith_innobase_storage_engine=1                  innodb 引擎 
-dwith_archive_storage_engine=1                     archive 引擎 
-dwith_blackhole_storage_engine=1              blackhole 引擎
常用的cmake参数(不同mysql版本可能有一些差异,请参考官方文档)
-dcmake_install_prefix= 指向mysql安装目录
-dinstall_sbindir=sbin 指向可执行文件目录(prefix/sbin)
-dmysql_datadir=/var/lib/mysql 指向mysql数据文件目录(/var/lib/mysql)
-dsysconfdir=/etc/mysql 指向mysql配置文件目录(/etc/mysql)
-dinstall_plugindir=lib/mysql/plugin 指向插件目录(prefix/lib/mysql/plugin)
-dinstall_mandir=share/man 指向man文档目录(prefix/share/man)
-dinstall_sharedir=share 指向aclocal/mysql.m4安装目录(prefix/share)
-dinstall_libdir=lib/mysql 指向对象代码库目录(prefix/lib/mysql)
-dinstall_includedir=include/mysql 指向头文件目录(prefix/include/mysql)
-dinstall_infodir=share/info 指向info文档存放目录(prefix/share/info)
prefix官方推荐设为/usr
storage engine相关
类型csv,myisam,myisammrg,heap,innobase,archive,blackhole
若想启用某个引擎的支持:-dwith__storage_engine=1
如:
-dwith_innobase_storage_engine=1
-dwith_archive_storage_engine=1
-dwith_blackhole_storage_engine=1
若想禁用某个引擎的支持:-dwithout__storage_engine=1
如:
-dwithout_example_storage_engine=1
-dwithout_federated_storage_engine=1
-dwithout_partition_storage_engine=1
library相关
-dwith_readline=1 启用readline库支持(提供可编辑的命令行)
-dwith_ssl=system 启用ssl库支持(安全套接层)
-dwith_zlib=system 启用libz库支持(zib、gzib相关)
-dwtih_libwrap=0 禁用libwrap库(实现了通用tcp包装的功能,为网络服务守护进程使用)
-dmysql_tcp_port=3306 指定tcp端口为3306
-dmysql_unix_addr=/tmp/mysqld.sock 指定mysql.sock路径
-denabled_local_infile=1 启用本地数据导入支持
-dextra_charsets=all 启用额外的字符集类型(默认为all)
-ddefault_charset=utf8 指定默认的字符集为utf8
-ddefault_collation=utf8_general_ci 设定默认排序规则(utf8_general_ci快速/utf8_unicode_ci准确)
-dwith_embedded_server=1 编译嵌入式服务器支持
-dmysql_user=mysql 指定mysql用户(默认为mysql)
-dwith_debug=0 禁用debug(默认为禁用)
-denable_profiling=0 禁用profiling分析(默认为开启)
2. mysql 编译时出现错误及解决方案
错误1:could not find curses (missing:  curses_library curses_include_path) 
1. centos 下执行:yum -y install ncurses-devel 
ubuntu 下执行:apt-get install libncurses5 libncurses5-dev 
2. 删除 cmakecache.txt,重新运行cmake
bitscn.com
其它类似信息

推荐信息