mysql-5.5.33编译安装

下载mysql编译工具:cmake,网站:https://cmake.org/download/

tar xf cmake-3.5.2.tar.gz
./bootstrap
make 
make install

或者用yum安装:yum install cmake

创建mysql用户和组:
groupadd -r mysql -g 36 
useradd mysql -g mysql -u 36 -r

安装编译工具:

yum -y install ncurses-devel

yum install  -y gcc-c++

编译mysql:
mkdir /data/db/mysql/port/{data,binlog} -pv
chown -R mysql:mysql /data/db/

cd mysql-5.5.33
cmake . -DCMAKE_INSTALL_PREFIX=/data/db/mysql/ -DMYSQL_DATADIR=/data/db/mysql/port/data/ -DSYSCONFDIR=/data/db/mysql/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DMYSQL_UNIX_ADDR=/data/db/mysql/port/mysql.sock -DWITH_LIBWRAP=0 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci

make

make install

配置mysql:
cd /data/db/mysql/
mkdir etc
cp support-files/my-large.cnf etc/my.cnf

grep -v '^#' etc/my.cnf

[client]
port = 3306
socket = /data/db/mysql/port/mysql.sock


[mysqld]
port = 3306
socket = /data/db/mysql/port/mysql.sock
datadir = /data/db/mysql/port/data
skip-external-locking
key_buffer_size = 256M
max_allowed_packet = 1M
table_open_cache = 256
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size= 16M
thread_concurrency = 8
log-bin = /data/db/mysql/port/binlog

cp support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld 
chkconfig --add mysqld
ln -sv /data/db/mysql /usr/local/mysql
./scripts/mysql_install_db --datadir=/data/db/mysql/port/data/ --user=mysql

mysql-5.5.33报错:CMake Error: CMAKE_CXX_COMPILER not set

系统环境:Centos 6.5 64位

数据库版本:mysql-5.5.33.tar.gz

准备工作:

# yum install cmake

新建用户以安全方式运行进程:

# groupadd -r mysql

# useradd -g mysql -r -s /sbin/nologin -M -d /data/mysql mysql

# chown -R mysql:mysql /data/mysql

卸载系统中旧的mysql版本

# rpm -e mysql-libs --nodeps

将源码包放到 /usr/local/src下并解压

# tar xf mysql-5.5.33.tar.gz && cd mysql-5.5.33

编译安装mysql

# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

>-DSYSCONFDIR=/etc -DMYSQL_DATADIR=/data/mysql \

>-DWITH_INNOBASE_STORAGE_ENGINE=1 \

>-DWITH_ARCHIVE_STORAGE_ENGINE=1 \

>-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \

>-DWITH_READLINE=1 -DWITH_SSL=system \

>-DWITH_ZLIB=system -DWITH_LIBWRAP=0 \

>-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \

>-DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci

检查系统环境过程中报错:

CMake Error at /usr/share/cmake/Modules/CMakeCXXInformation.cmake:37 (get_filename_component):

  get_filename_component called with incorrect number of arguments

Call Stack (most recent call first):

  CMakeLists.txt:3 (PROJECT)

CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage

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

-- Performing Test HAVE_PEERCRED - Failed

-- Configuring incomplete, errors occurred!

See also "/usr/local/src/mysql-5.5.33/CMakeFiles/CMakeOutput.log".

See also "/usr/local/src/mysql-5.5.33/CMakeFiles/CMakeError.log".

个人感觉比较诡异,在网上查了片刻,有的是需要安装 gcc相关的编译器,感觉似乎是这样

# yum install gcc gcc-c++

删除产生的CMakeCache.txt文件,然后重新运行cmake

# rm -r CMakeCache.txt

-- Configuring done

CMake Warning (dev) in sql/CMakeLists.txt:

  Policy CMP0022 is not set: INTERFACE_LINK_LIBRARIES defines the link

  interface.  Run "cmake --help-policy CMP0022" for policy details.  Use the

  cmake_policy command to set the policy and suppress this warning.

  Target "mysqld" has an INTERFACE_LINK_LIBRARIES property which differs from

  its LINK_INTERFACE_LIBRARIES properties.

  INTERFACE_LINK_LIBRARIES:

    -lpthread;sql;mysys

  LINK_INTERFACE_LIBRARIES:

    rt

This warning is for project developers.  Use -Wno-dev to suppress it.

-- Generating done

-- Build files have been written to: /usr/local/src/mysql-5.5.33

说明编译环境ok

接下来可以 make && makeinstall 了,这个需要时间会长一点,看机器的性能了。

为了在安装过程中尽量少出现报错,最好先 yum安装一些必需的编译工具和库文件(安装的比较多,方便以后编译安装php、nginx等):

# yum install make  autoconf automake curl curl-devel gcc gcc-c++ gtk+-devel zlib-devel openssl openssl-devel pcre-devel  perl kernel-headers compat*  cpp glibc libgomp libstdc++-devel keyutils-libs-devel libsepol-devel libselinux-devel krb5-devel  libXpm* freetype freetype-devel freetype* fontconfig fontconfig-devel libpng* ncurses* libtool* libxml2-devel  bison libaio-devel

©️2020 CSDN 皮肤主题: 书香水墨 设计师:CSDN官方博客 返回首页