lanmp 架构-mysql原码编译

                 Mysql源码编译安装

1.mysql-5.6.10.tar.gz特别大 ,虚拟机内存较少时会导致快照崩掉、所以用mysql-5.5.12.tar.gz

2.cmake比configure编译过程更详细

3.每次运行完都会产生一个缓存文件,再次编译时需删除缓存

mysql的官方网站:www.mysql.com

4.postfix默认支持mysql-libs,若卸载掉mysql-libs,postfix起不来

[root@server79 mysql-5.5.12]# ldd /usr/sbin/postfix   //缺一不可

linux-vdso.so.1 =>  (0x00007fff62bff000)

libldap-2.4.so.2 => /lib64/libldap-2.4.so.2 (0x00007fb47245a000)

liblber-2.4.so.2 => /lib64/liblber-2.4.so.2 (0x00007fb47224b000)

libpcre.so.0 => /lib64/libpcre.so.0 (0x00007fb47201e000)

libmysqlclient.so.16 => /usr/lib64/mysql/libmysqlclient.so.16 (0x00007fb471c9c000)

libm.so.6 => /lib64/libm.so.6 (0x00007fb471a18000)

libsasl2.so.2 => /usr/lib64/libsasl2.so.2 (0x00007fb4717fd000)

libssl.so.10 => /usr/lib64/libssl.so.10 (0x00007fb4715a2000)

libcrypto.so.10 => /usr/lib64/libcrypto.so.10 (0x00007fb471208000)

libdl.so.2 => /lib64/libdl.so.2 (0x00007fb471003000)

libz.so.1 => /lib64/libz.so.1 (0x00007fb470ded000)

libdb-4.7.so => /lib64/libdb-4.7.so (0x00007fb470a79000)

libnsl.so.1 => /lib64/libnsl.so.1 (0x00007fb47085f000)

libresolv.so.2 => /lib64/libresolv.so.2 (0x00007fb470645000)

libc.so.6 => /lib64/libc.so.6 (0x00007fb4702b3000)

libssl3.so => /usr/lib64/libssl3.so (0x00007fb470076000)

libsmime3.so => /usr/lib64/libsmime3.so (0x00007fb46fe4a000)

libnss3.so => /usr/lib64/libnss3.so (0x00007fb46fb0f000)

libnssutil3.so => /usr/lib64/libnssutil3.so (0x00007fb46f8e8000)

libplds4.so => /lib64/libplds4.so (0x00007fb46f6e4000)

libplc4.so => /lib64/libplc4.so (0x00007fb46f4df000)

libnspr4.so => /lib64/libnspr4.so (0x00007fb46f2a1000)

libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007fb46f06a000)

libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007fb46ee27000)

libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007fb46eb48000)

libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007fb46e944000)

libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x00007fb46e717000)

/lib64/ld-linux-x86-64.so.2 (0x00007fb4728c7000)

libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fb46e4fa000)

libfreebl3.so => /lib64/libfreebl3.so (0x00007fb46e297000)

libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007fb46e08c000)

libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007fb46de89000)

libselinux.so.1 => /lib64/libselinux.so.1 (0x00007fb46dc69000)

下载源码:

可从官方网站下载

lftp 192.168.0.251:/pub/docs/lamp/update/lnmp> get mysql-5.5.12.tar.gz

[root@server79 ~]# tar zxf mysql-5.5.12.tar.gz

安装编译工具

[root@server79 mysql-5.5.12]# yum install cmake -y

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

#安装目录

-DMYSQL_DATADIR=/usr/local/mysql/data \

#数据库存放目录

-DMYSQL_UNIX_ADDR=/usr/local/mysql/data/mysql.sock \ #Unix socket 文件路径

-DWITH_MYISAM_STORAGE_ENGINE=1 \

#安装 myisam 存储引擎

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

#安装 innodb 存储引擎

-DWITH_ARCHIVE_STORAGE_ENGINE=1 \

#安装 archive 存储引擎

-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \

#安装 blackhole 存储引擎

-DWITH_PARTITION_STORAGE_ENGINE=1 \

#安装数据库分区

-DENABLED_LOCAL_INFILE=1 \

#允许从本地导入数据

-DWITH_READLINE=1 \

#快捷键功能

-DWITH_SSL=yes \

#支持 SSL

-DDEFAULT_CHARSET=utf8 \

#使用 utf8 字符

-DDEFAULT_COLLATION=utf8_general_ci \

#校验字符

-DEXTRA_CHARSETS=all \

#安装所有扩展字符集

-DMYSQL_TCP_PORT=3306 \

编译:

[root@server79 mysql-5.5.12]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/lnmp/mysql -DMYSQL_DATADIR=/usr/local/lnmp/mysql/data -DMYSQL_UNIX_ADDR=/usr/local/lnmp/mysql/data/mysql.sock  -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all

问题1:

remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.

解决:

[root@server79 mysql-5.5.12]# yum install ncurses-devel -y

[root@server79 mysql-5.5.12]# rm -fr CMakeCache.txt

问题2:

CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage

CMake Error: Internal CMake error, TryCompile configure of cmake failed

-- Performing Test HAVE_PEERCRED - Failed

Warning: Bison executable not found in PATH

-- Configuring incomplete, errors occurred!

解决:

[root@server79 mysql-5.5.12]# yum install gcc-c++ -y

错误3:Warning: Bison executable not found in PATH

解决:

[root@server79 mysql-5.5.12]# yum install bison -y

[root@server79 mysql-5.5.12]# rm -fr CMakeCache.txt

[root@server79 mysql-5.5.12]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/lnmp/mysql -DMYSQL_DATADIR=/usr/local/lnmp/mysql/data -DMYSQL_UNIX_ADDR=/usr/local/lnmp/mysql/data/mysql.sock  -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all

[root@server79 mysql-5.5.12]# make && make install


你可能感兴趣的:(lanmp,mysql原码编译)