VMware15
CentOS7版本:最小化安装,CentOS Linux release 7.8.2003 (Core),硬盘至少40G,内存至少3G,SWAP 2G
MYSQL版本:mysql-boost-8.0.21
关闭selinux,编辑vim /etc/selinux/config
,改为 SELINUX=disabled
保存退出reboot
yum -y install gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel mlocate
yum -y install bzip2 lrzsz ncurses-devel
updatedb ----更新数据库
下载地址:http://cmake.org/files/v3.18/cmake-3.18.0.tar.gz
xshell连上,cd /usr/src, rz选择文件上传
解压:tar -xzvf cmake-3.18.0.tar.gz
删除:rm -rf cmake-3.18.0.tar.gz
mkdir -p /usr/local/cmake ----创建cmake安装目录
cd /usr/src/cmake-3.18.0
./configure --prefix=/usr/local/cmake ----prefix设置安装到哪
make (5分钟左右) ==》make install
ln -s /usr/local/cmake/bin/cmake /usr/bin ----创建软链接
升级到gcc 9.3
yum -y install centos-release-scl
yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
scl enable devtoolset-9 bash
echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile
source /etc/profile
cd /usr/src
下载地址: https://mirrors.ustc.edu.cn/gnu/gcc/gcc-10.1.0/gcc-10.1.0.tar.gz
解压:tar -xzvf gcc-10.1.0.tar.gz
删除:rm -rf gcc-10.1.0.tar.gz
下载四个文件(./contrib/download_prerequisites里面有四个文件版本)
http://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2
http://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2
http://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz
http://gcc.gnu.org/pub/gcc/infrastructure/isl-0.18.tar.bz2
xshell连上,cd /usr/src/gcc-10.1.0/, rz上传四个文件到gcc解压目录
mkdir -p /usr/local/gcc 创建gcc安装目录
./contrib/download_prerequisites ----提示四个确定即可
./configure --prefix=/usr/local/gcc -enable-checking=release -enable-languages=c,c++ -disable-multilib
make -j4 (两小时左右)
make install
删除以前版本:yum -y remove gcc
设置环境变量:echo "export PATH=/usr/local/gcc/bin:$PATH" >> /etc/profile.d/gcc.sh
加载环境变量:source /etc/profile.d/gcc.sh
命令找动态库:find / -name libstdc++.so.6
出现的目录复制下来替换掉
rm -rf /usr/lib64/libstdc++.so.6
cp /usr/local/gcc/lib64/libstdc++.so.6 /usr/lib64/
查看版本 gcc -v
把mysql-boost-8.0.21.tar.gz放到cd /usr/src 目录下
cd /usr/src
解压:tar -xzvf mysql-boost-8.0.21.tar.gz
删除:rm -rf mysql-boost-8.0.21.tar.gz
locate terminal.c ----显示出结果,把那个terminal.c 的文件编辑一下:
vim /usr/src/mysql-8.0.21/extra/libedit/libedit-20190324-3.1/src/terminal.c
创建文件夹,安装目录,数据目录, boost库目录, 日志目录,运行文件目录
mkdir -p /usr/local/mysql
mkdir -p /usr/local/mysql/var
mkdir -p /usr/local/boost
mkdir -p /usr/local/mysql/log/mysqlbin/mysql-bin/
mkdir -p /usr/local/mysql/run/
创建专用mysql账户,并设置所属主组
useradd mysql -s /sbin/nologin
chown -R mysql:mysql /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql/var/
chown -R mysql:mysql /usr/local/mysql/log/
chown -R mysql:mysql /usr/local/mysql/run/
cd /usr/src/mysql-8.0.21/
设置安装参数,参数详解查看这篇:https://www.cnblogs.com/martinzhang/p/3455681.html
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/var -DSYSCONFDIR=/etc -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/boost -DFORCE_INSOURCE_BUILD=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_TCP_PORT=3306 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DWITH_EXTRA_CHARSETS=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DMYSQL_UNIX_ADDR=/tmp/mysql.sock
vim storage/innobase/buf/buf0buf.cc ----编辑,在开头添加 #include "sys/syscall.h"
make -j4 (开始make -j8到报错, 换成j4再报错,最后换成j2无错)
如果报错:
编辑提示的那个文件,1226行,红色文字改成下面那行绿色文字,再make…
cd /usr/local/mysql/bin
./mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/var --log-bin=/usr/local/mysql/log/mysqlbin/mysql-bin
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
vim /etc/init.d/mysqld
46行 basedir=/usr/local/mysql
47行 datadir=/usr/local/mysql/var
mkdir /var/log/mariadb
touch /var/log/mariadb/mariadb.log
chown -R mysql:mysql /var/log/mariadb/
vim /etc/my.cnf
[client]
default-character-set=utf8
#password = your_password
port = 3306
socket = /tmp/mysql.sock
#服务端配置
[mysqld]
character-set-server=utf8mb4
basedir = /usr/local/mysql/
datadir = /usr/local/mysql/var/
port = 3306
socket = /tmp/mysql.sock
join_buffer_size = 128M
sort_buffer_size = 2M
read_rnd_buffer_size = 2M
# 主从配置
server-id = 1
# Innodb配置
innodb_data_home_dir = /usr/local/mysql/var
innodb_log_group_home_dir = /usr/local/mysql/var
innodb_buffer_pool_size = 129M
# 慢日志设置
slow_query_log=1
long_query_time=2
slow_query_log_file=/usr/local/mysql/log/slow_query.log
# 错误日志配置
log-error = /usr/local/mysql/log/error.log
pid-file = /usr/local/mysql/run/mysql.pid
# bin-log二进制日志设置
log-bin=/usr/local/mysql/log/mysqlbin/mysql-bin
binlog_format=statement
#其他配置
[mysqldump]
quick
[mysql]
auto-rehash
[mysqld_safe]
open-files-limit = 8192
vim /etc/profile ----第74行添加如下
export PATH=$PATH:/usr/local/mysql/bin
vim ~/.bashrc ----最后一行添加 source /etc/profile
service mysqld start ----开启服务
service mysqld restart ----重启服务
service mysqld stop ----停止服务
service mysqld status ----服务状态
如果报错再执行一遍第一步
chkconfig mysqld on ----mysql服务加入开机自启
reboot
mysql_secure_installation