Centos7源码编译安装mysql8
前面介绍了很多关于mysql的文章,下面主要介绍一下mysql8的源码编译安装
一 基本环境
[[email protected] ~]# cd /usr/local/src/
[[email protected] src]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
[[email protected] src]# uname -r
5.2.14-1.el7.elrepo.x86_64
二 准备
2.1 安装依赖包
[[email protected] src]# yum -y install wget cmake gcc gcc-c ncurses ncurses-devel libaio-devel openssl openssl-devel
2.2 下载包
[[email protected] src]# wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-boost-8.0.17.tar.gz
2.3 解压并创建用户和目录
[[email protected] src]# tar -xf mysql-boost-8.0.17.tar.gz
[[email protected] src]# cd mysql-8.0.17/
[[email protected] mysql-8.0.17]# groupadd mysql
[[email protected] mysql-8.0.17]# useradd -r -g mysql -s /sbin/nologin mysql
[[email protected] mysql-8.0.17]# mkdir -p /usr/local/mysql
[[email protected] mysql-8.0.17]# chown -R mysql.mysql /usr/local/mysql/
[[email protected] mysql-8.0.17]# chown -R mysql.mysql /data/mysql/
[[email protected] mysql-8.0.17]# chmod -R 755 /data/mysql/
[[email protected] mysql-8.0.17]# chmod -R 755 /usr/local/mysql/
三 安装
3.1 编译安装
[[email protected] mysql-8.0.17]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
> -DMYSQL_DATADIR=/data/mysql
> -DSYSCONFDIR=/etc
> -DMYSQL_TCP_PORT=3306
> -DWITH_BOOST=~/mysql-8.0.12/boost
> -DDEFAULT_CHARSET=utf8
> -DDEFAULT_COLLATION=utf8_general_ci
> -DENABLED_LOCAL_INFILE=ON
> -DWITH_INNODB_MEMCACHED=ON
> -DWITH_INNOBASE_STORAGE_ENGINE=1
> -DWITH_FEDERATED_STORAGE_ENGINE=1
> -DWITH_BLACKHOLE_STORAGE_ENGINE=1
> -DWITH_ARCHIVE_STORAGE_ENGINE=1
> -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1
> -DWITH_PERFSCHEMA_STORAGE_ENGINE=1
-- Running cmake version 2.8.12.2
3.2 安装cmake 3.5以上版本
[[email protected] mysql-8.0.17]# yum -y remove cmake
下载二进制包
[[email protected] mysql-8.0.17]# cd /usr/local/src/
[[email protected] src]# wget https://github.com/Kitware/CMake/releases/download/v3.15.3/cmake-3.15.3-Linux-x86_64.tar.gz
[[email protected] src]# tar -xf cmake-3.15.3-Linux-x86_64.tar.g
[[email protected] src]# cp -r cmake-3.15.3-Linux-x86_64 /usr/local/cmake
设置环境变量
[[email protected] src]# vi /etc/profile
export CMAKE_PATH=/usr/local/cmake
export PATH=$PATH:$CMAKE_PATH/bin
[[email protected] src]# source /etc/profile
[[email protected] src]# cmake –version
[[email protected] src]# cd mysql-8.0.17/
[[email protected]86-64-Minimal-1810 mysql-8.0.17]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc -DMYSQL_TCP_PORT=3306 -DWITH_BOOST=~/mysql-8.0.12/boost -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DENABLED_LOCAL_INFILE=ON -DWITH_INNODB_MEMCACHED=ON -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1
[[email protected] mysql-8.0.17]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc -DMYSQL_TCP_PORT=3306 -DWITH_BOOST=~/mysql-8.0.12/boost -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DENABLED_LOCAL_INFILE=ON -DWITH_INNODB_MEMCACHED=ON -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DFORCE_INSOURCE_BUILD=1
3.3 安装GCC高版本
下载源码包
[[email protected] mysql-8.0.17]# cd /usr/local/src/
[[email protected] src]# wget https://mirrors.ustc.edu.cn/gnu/gcc/gcc-9.2.0/gcc-9.2.0.tar.gz
[[email protected] src]# tar -xf gcc-9.2.0.tar.gz
[[email protected] src]# cd gcc-9.2.0
[[email protected] src]# ./contrib/download_prerequisites
2019-09-18 15:50:02 URL: ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2 [2383840] -> "./gmp-6.1.0.tar.bz2" [1] 2019-09-18 15:50:12 URL: ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2 [1279284] -> "./mpfr-3.1.4.tar.bz2" [2] 2019-09-18 15:50:22 URL: ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz [669925] -> "./mpc-1.0.3.tar.gz" [2] 2019-09-18 15:50:32 URL: ftp://gcc.gnu.org/pub/gcc/infrastructure/isl-0.18.tar.bz2 [1658291] -> "./isl-0.18.tar.bz2" [2] gmp-6.1.0.tar.bz2: OK mpfr-3.1.4.tar.bz2: OK mpc-1.0.3.tar.gz: OK isl-0.18.tar.bz2: OK All prerequisites downloaded successfully.
[[email protected] gcc-9.2.0]# ./configure --prefix=/usr/local/gcc --enable-bootstrap --enable-checking=release --enable-languages=c,c --disable-multilib
[[email protected] gcc-9.2.0]# time make -j4
花费时间比较久
[[email protected] gcc-9.2.0]# make install
设置环境变量
[[email protected] gcc-9.2.0]# echo "export PATH=/usr/local/gcc/bin:$PATH" >> /etc/profile.d/gcc.sh
[[email protected] gcc-9.2.0]# source /etc/profile.d/gcc.sh
[[email protected] gcc-9.2.0]# ln -sv /usr/local/gcc/include/ /usr/include/gcc
[[email protected] gcc-9.2.0]# ldconfig –v
[[email protected] gcc-9.2.0]# ldconfig -p |grep gcc
[[email protected] gcc-9.2.0]# gcc –v
[[email protected] gcc-9.2.0]# cd /usr/local/src/mysql-8.0.17/
[[email protected] mysql-8.0.17]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc -DMYSQL_TCP_PORT=3306 -DWITH_BOOST=~/mysql-8.0.12/boost -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DENABLED_LOCAL_INFILE=ON -DWITH_INNODB_MEMCACHED=ON -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DFORCE_INSOURCE_BUILD=1
[[email protected] mysql-8.0.17]# yum –y remove gcc
报错
[[email protected] mysql-8.0.17]# ln -s /usr/local/gcc/bin/c /usr/bin/
[[email protected] mysql-8.0.17]# ln -s /usr/local/gcc/bin/gcc /usr/bin/cc
3.4 再次编译安装
[[email protected] mysql-8.0.17]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc -DMYSQL_TCP_PORT=3306 -DWITH_BOOST=/usr/local/src/mysql-8.0.17/boost -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DENABLED_LOCAL_INFILE=ON -DWITH_INNODB_MEMCACHED=ON -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DFORCE_INSOURCE_BUILD=1
[[email protected] mysql-8.0.17]#make
[[email protected] mysql-8.0.17]#make Install
3.5 初始化数据库
[[email protected] mysql-8.0.17]# cd /usr/local/mysql/bin/
[[email protected] bin]# ./mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql
[[email protected]inimal-1810 bin]# vi /etc/my.cnf
[client] port=3306 socket=/tmp/mysql.sock default-character-set=utf8 #user=root #password=123 [mysqld] server-id=1 #skip-grant-tables port=3306 user=mysql max_connections=200 socket=/tmp/mysql.sock basedir=/usr/local/mysql datadir=/data/mysql pid-file=/data/mysql/mysql.pid init-connect=‘SET NAMES utf8‘ character-set-server=utf8 default-storage-engine=INNODB log_error=/data/mysql/mysql-error.log slow_query_log_file=/data/mysql/mysql-slow.log [mysqldump] quick max_allowed_packet=16M
[[email protected] bin]# echo "PATH=/usr/local/mysql/bin:$PATH" >> /etc/profile
[[email protected] bin]# source /etc/profile
[[email protected] bin]# cp /usr/local/src/mysql-8.0.17/support-files/mysql.server /etc/init.d/mysqld
[[email protected] bin]# vim /etc/init.d/mysqld
basedir=/usr/local/mysql
datadir=/data/mysql
[[email protected] bin]# chmod x /etc/init.d/mysqld
[[email protected] bin]# /etc/init.d/mysqld start
3.6 登陆
可以无密码登录
[[email protected] bin]# mysql -u root -p
数据库初步安装完成,后续在做其他实验
温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/a/22985.html
- 上一篇:mongodb自身简单监控
- 下一篇:sybase 查询表对应的段