本文实例为大家分享了Centos6.4编译mysql 8.0.0 安装配置方法,供大家参考,具体内容如下
操作系统说明:CentOS 6.4
数据库版本:MySQL 8.0.0
一.环境准备
1
2
3
4
|
yum install ncurses-devel -y
yum install libaio -y
yum install glibc-devel.i686 glibc-devel -y
yum install gcc gcc-c++ -y
|
另外,MySQL8.0需要用gcc的版本为 4.8以上,而centos 6.4通过yum只能安装到4.4.7,所以在安装mysql8.0之前需要手动安装更高版本的gcc,我这里以gcc-8.8.2为例:
1
2
3
|
wget ftp : //ftp .gnu.org /gnu/gcc/gcc-4 .8.2 /gcc-4 .8.2. tar .gz
tar xf gcc-4.8.2. tar .gz
cd gcc-4.8.2
|
# 载编译需要的依赖包:./contrib/download_prerequisites
./configure --prefix=/usr/local/gcc-4.8.2/ --enable-bootstrap --enable-threads=posix --enable-languages=c,c++,objc,obj-c++
make &&make install
说明:make的时间会很长。
安装完后,还需要将原来的gcc环境用新版本的gcc替换掉,否则mysql在安装时还是用的原来的gcc:
1
2
3
4
|
mv /usr/bin/gcc /usr/bin/gcc447
mv /usr/bin/g ++ /usr/bin/g ++447
mv /usr/bin/c ++ /usr/bin/c ++447
mv /usr/bin/cc /usr/bin/cc447
|
1
2
3
4
|
ln -s /usr/local/gcc-4 .8.2 /bin/gcc /usr/bin/gcc
ln -s /usr/local/gcc-4 .8.2 /bin/g ++ /usr/bin/g ++
ln -s /usr/local/gcc-4 .8.2 /bin/c ++ /usr/bin/c ++
ln -s /usr/local/gcc-4 .8.2 /bin/gcc /usr/bin/cc
|
1
2
|
mv /usr/lib64/libstdc ++.so.6 /usr/lib64/libstdc ++.so.6.bak
ln -s /usr/local/gcc-4 .8.2 /lib64/libstdc ++.so.6.0.18 /usr/lib64/libstdc ++.so.6
|
解决如下问题:
接着,安装boost库:
1
2
3
4
5
6
|
wget -c http: //sourceforge .net /projects/ ... oost_1_60_0. tar .bz2 --no-check-certificate
tar xf boost_1_60_0. tar .bz2\?r\=\&ts\=1479114685\&use_mirror\=ncu
cd boost_1_60_0
. /bootstrap .sh
. /b2 stage threading=multi link=shared
. /b2 install threading=multi link=shared
|
二.安装mysql8.0
# 下载和解压mysql
wget -c http://dev.mysql.com/get/Downloa ... st-8.0.0-dmr.tar.gz
tar xf mysql-boost-8.0.0-dmr.tar.gz
# 编译安装mysql
1
2
3
4
5
6
7
8
9
10
11
12
|
cd mysql-8.0.0-dmr
cmake -DCMAKE_INSTALL_PREFIX= /usr/local/mysql \
-DMYSQL_DATADIR= /usr/local/mysql/data/ -DSYSCONFDIR=\etc\mysql \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_BOOST= /tmp/boost_1_60_0/
make
make install
|
# 新增mysql用户和组,并配置mysql用户对数据库目录的权限
1
2
3
|
groupadd mysql
useradd -g mysql mysql
chown mysql.mysql /usr/local/mysql -R
|
# 初始化mysql
1
2
3
4
5
|
cd /usr/local/mysql
bin /mysqld --initialize --user=mysql --basedir= /usr/local/mysql --datadir= /usr/local/mysql/data/
bin /mysql_ssl_rsa_setup
|
# 配置文件
1
2
3
4
5
6
7
8
9
10
11
|
cp . /support-files/my-default .cnf /etc/my .cnf
vim /etc/my .cnf
[mysqld]
datadir= /usr/local/mysql/data/
socket= /var/lib/mysql/mysql .sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
pid- file = /var/run/mysqld/mysqld .pid
log-error= /var/log/mysqld .log
|
# 创建进程文件目录
1
2
|
mkdir /var/run/mysqld
chown mysql /var/run/mysqld/ -R
|
# 设置环境变量
1
2
|
echo "export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/sbin" >> /etc/profile
source /etc/profile
|
# 设置开机启动脚本
1
2
3
4
|
cd /usr/ local /mysql
cp support-files/mysql.server /etc/init.d/mysql.server
chkconfig mysql.server on
service mysql.server start
|
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。