gcc 9.2.0 编译安装mysql 8.0.17

环境说明:

CentOS Linux release 7.4.1708 (Core)
内核版本: 3.10.0-693.el7.x86_64
工作目录:/usr/local/src/
mysql 安装目录:/apps/program
其它程序安装目录:/usr/local/程序名+版本号

安装源码准备

cd /usr/local/src/
wget https://mirrors.ustc.edu.cn/gnu/gmp/gmp-6.1.2.tar.xz
wget https://mirrors.ustc.edu.cn/gnu/mpfr/mpfr-4.0.2.tar.gz
wget https://mirrors.ustc.edu.cn/gnu/mpc/mpc-1.1.0.tar.gz
wget https://mirrors.ustc.edu.cn/gnu/gcc/gcc-9.2.0/gcc-9.2.0.tar.gz
wget https://github.com/Kitware/CMake/releases/download/v3.15.2/cmake-3.15.2.tar.gz
wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-boost-8.0.17.tar.gz

安装依赖

yum -y install epel-release
yum -y group install "Development Tools"
mysql 依赖
yum -y install ncurses-devel openssl openssl-devel bison

安装gcc 源码编译依赖

## 先编译gmp->mpfr->mpc

cd  /usr/local/src/
编译: gmp-6.1.2
tar -xvf gmp-6.1.2.tar.xz
cd gmp-6.1.2
./configure --prefix=/usr/local/gmp-6.1.2
make -j $(nproc)
make install
cd ../
编译:mpfr-4.0.2
tar -xvf mpfr-4.0.2.tar.gz
cd mpfr-4.0.2
./configure --prefix=/usr/local/mpfr-4.0.2 --with-gmp=/usr/local/gmp-6.1.2
make -j $(nproc)
make install
cd ../
编译:mpc-1.1.0
tar -xvf mpc-1.1.0.tar.gz
cd mpc-1.1.0
./configure --prefix=/usr/local/mpc-1.1.0 --with-mpfr=/usr/local/mpfr-4.0.2  --with-gmp=/usr/local/gmp-6.1.2
make -j $(nproc)
make install
# 把mpfr lib 加入 ld.so.conf 不然gcc 编译报错
echo /usr/local/mpfr-4.0.2/lib  >> /etc/ld.so.conf
ldconfig

编译安装gcc

cd /usr/local/src/
tar -xvf gcc-9.2.0.tar.gz
cd gcc-9.2.0
./configure --prefix=/usr/local/gcc-9.2.0                   -enable-threads=posix                   -disable-checking                   -disable-multilib                   -enable-languages=c,c++                   --with-gmp=/usr/local/gmp-6.1.2                   --with-mpfr=/usr/local/mpfr-4.0.2                   --with-mpc=/usr/local/mpc-1.1.0                   --with-tune=generic                   --with-arch_32=x86-64

make -j $(nproc)
make install -j $(nproc)
##备份旧 gcc 可执行文件
 mv /usr/bin/gcc /usr/bin/gcc.old
 mv /usr/bin/g++ /usr/bin/g++.old
 mv /usr/bin/c++ /usr/bin/c++.old
 mv /usr/bin/cpp /usr/bin/cpp.old
 mv /usr/bin/gcov /usr/bin/gcov.old
 ## 创建最新gcc 执行文件软链
 ln -sf /usr/local/gcc-9.2.0/bin/* /usr/bin/
 ## 删除lib64 目录下.py 文件不然ldconfig 报错
 rm -rf /usr/local/gcc-9.2.0/lib64/libstdc++.so.6.0.27-gdb.py
 echo /usr/local/gcc-9.2.0/lib64 >> /etc/ld.so.conf
ldconfig
## 复制libstdc++.so.6.0.27  /lib64/
cp /usr/local/gcc-9.2.0/lib64/libstdc++.so.6.0.27 /lib64/
# 创建软链 libstdc++.so.6
cd /lib64
ln  -sf libstdc++.so.6.0.27 libstdc++.so.6
## 查看是否最新版本
strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX

编译安装cmake

cd  /usr/local/src/
tar -xvf cmake-3.15.2.tar.gz
cd cmake-3.15.2
./configure --prefix=/usr/local/cmake-3.15.2
gmake -j $(nproc)
gmake install -j $(nproc)
# 创建cmake 软链
 ln -sf /usr/local/cmake-3.15.2/bin/cmake /bin/cmake3

编译mysql

cd   /usr/local/src/
tar -xvf mysql-boost-8.0.17.tar.gz
cd mysql-boost-8.0.17
cmake3 . -DCMAKE_INSTALL_PREFIX=/apps/program/mysql                 -DMYSQL_DATADIR=/apps/program/data                 -DSYSCONFDIR=/etc                 -DENABLED_LOCAL_INFILE=ON                 -DWITH_INNODB_MEMCACHED=ON                 -DWITH_INNOBASE_STORAGE_ENGINE=1                 -DWITH_ARC\H\I\G\VE_STORAGE_ENGINE=1 \           # 请删除\ 跟\G是敏感词发不出去
                -DWITH_BLACKHOLE_STORAGE_ENGINE=1                 -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1                 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1                 -DWITH_READLINE=1                 -DFORCE_INSOURCE_BUILD=1                 -DMYSQL_UNIX_ADDR=/apps/program/tmp/mysql.sock                 -DWITH_SSL=system                 -DWITH_ZLIB=system                 -DWITH_BOOST=./boost/boost_1_69_0                 -DDEFAULT_CHARSET=utf8                 -DDEFAULT_COLLATION=utf8_general_ci
gmake -j $(nproc)
gmake install -j $(nproc)

## 说明: [ 36%] Building CXX object storage/innobase/CMakeFiles/innobase.dir/buf/buf0buf.cc.o
                /usr/src/mysql-8.0.17/storage/innobase/buf/buf0buf.cc: In function ‘void buf_pool_create(buf_pool_t*, ulint, ulint, std::mutex*, dberr_t&)’:
                /usr/src/mysql-8.0.17/storage/innobase/buf/buf0buf.cc:1220:44: error: ‘SYS_gettid’ was not declared in this scope
                1220 | setpriority(PRIO_PROCESS, (pid_t)syscall(SYS_gettid), -20);
                | ^~~~~~~~~~
                make[2]: *** [storage/innobase/CMakeFiles/innobase.dir/buf/buf0buf.cc.o] Error 1
                make[1]: *** [storage/innobase/CMakeFiles/innobase.dir/all] Error 2
                make: *** [all] Error 2
                                这样的错误的话检测gcc 软链是否创建lib64 是否t添加到ld.so.conf 并且生效
# 复制启动文件
cp support-files/mysql.server /etc/init.d/mysqld
chmod 700 /etc/init.d/mysqld

# 添加mysql 到环境变量
echo export PATH=$PATH:/apps/program/mysql/bin >>/etc/profile
source /etc/profile
echo /apps/program/mysql/lib >> /etc/ld.so.conf
ldconfig

# 创建mysql 账号
 useradd mysql -s /sbin/nologin -M
 # 创建mysql 所需文件加
 mkdir /apps/program/{data,tmp,logs} -p
 mkdir -p /apps/program/logs/{mysqld,backup_mysqld}
 # /apps/program mysql 账号权限
 chown -R mysql:mysql /apps/program 


编辑my.cnf 文件

vi /etc/my.cnf

[client]
port    = 3306
socket  = /apps/program/tmp/mysql.sock

[mysql]
no-auto-rehash
no-beep
default-character-set = utf8mb4
socket=/apps/program/tmp/mysql.sock
#prompt="\\@\\h \\d \\R:\\m:\\s> "
#tee="/apps/logs/mysql/audit.log"
#pager="less -i -n -S"
net-buffer-length=64K
unbuffered
max-allowed-packet = 2G # add by alading on 20151110

[mysqld]
user=mysql
bind-address=0.0.0.0
port=3306
mysqlx-port=33060
server-id=5
basedir=/apps/program/mysql
pid-file=/apps/program/tmp/mysql.pid
socket=/apps/program/tmp/mysql.sock
datadir=/apps/program/data
tmpdir=/apps/program/tmp
plugin-dir=/apps/program/mysql/lib/plugin
character-set-server = utf8mb4
skip-name-resolve = 1
# 为了兼容客户段程序不支持caching_sha2_password加密修改默认加密为mysql_native_password
default-authentication-plugin=mysql_native_password
default-time-zone = "+8:00"
#******security
safe-user-create
max-user-connections=2980
max-connect-errors=100000
secure-file-priv=/apps/program/tmp

open-files-limit    = 65535
back-log = 1024
max-connections = 512
max-connect-errors = 1000000
table-open-cache = 1024
table-definition-cache = 1024
table-open-cache-instances = 64
thread-stack = 512K
external-locking = FALSE
max-allowed-packet = 32M
sort-buffer-size = 4M
join-buffer-size = 4M
thread-cache-size = 768
interactive-timeout = 600
wait-timeout = 600
tmp-table-size = 32M
max-heap-table-size = 32M
slow-query-log = 1
log-timestamps = SYSTEM
slow-query-log-file = /apps/program/logs/mysqld/slow.log
log-error = /apps/program/logs/mysqld/error.log
long-query-time = 0.1
log-queries-not-using-indexes =1
log-throttle-queries-not-using-indexes = 60
min-examined-row-limit = 100
log-slow-admin-statements = 1
log-slow-slave-statements = 1
log-bin = /apps/program/logs/mysqld/mysql-bin
sync-binlog = 1
binlog-cache-size = 4M
max-binlog-cache-size = 2G
max-binlog-size = 1G

expire-logs-days = 3

master-info-repository = TABLE
relay-log-info-repository = TABLE
gtid-mode = on
enforce-gtid-consistency = 1
log-slave-updates
slave-rows-search-algorithms = ‘INDEX_SCAN,HASH_SCAN‘
binlog-format = row
binlog-checksum = 1
relay-log-recovery = 1
relay-log-purge = 1
key-buffer-size = 32M
read-buffer-size = 8M
read-rnd-buffer-size = 4M
bulk-insert-buffer-size = 64M
myisam-sort-buffer-size = 128M
myisam-max-sort-file-size = 10G
myisam-repair-threads = 1
lock-wait-timeout = 3600
explicit-defaults-for-timestamp = 1
innodb-thread-concurrency = 0
innodb-sync-spin-loops = 100
innodb-spin-wait-delay = 30

transaction-isolation = REPEATABLE-READ
#innodb-additional-mem-pool-size = 16M
innodb-buffer-pool-size = 4096M  # #for system 60%mem
innodb-buffer-pool-instances = 4  # change from 4 to default value 8 on 20150210
innodb-buffer-pool-load-at-startup = 1
innodb-buffer-pool-dump-at-shutdown = 1
innodb-data-file-path = ibdata1:1G:autoextend
innodb-flush-log-at-trx-commit = 1
innodb-log-buffer-size = 32M
innodb-log-file-size = 2G
innodb-log-files-in-group = 2
innodb-max-undo-log-size = 4G
innodb-undo-directory = /apps/program/undo_space
innodb-undo-tablespaces = 95

innodb-io-capacity = 4000  # ssd 可以调整更大
innodb-io-capacity-max = 8000  # ssd 可以调整更大
innodb-flush-sync = 0
innodb-flush-neighbors = 0
innodb-write-io-threads = 8
innodb-read-io-threads = 8
innodb-purge-threads = 4
innodb-page-cleaners = 4
innodb-open-files = 65535
innodb-max-dirty-pages-pct = 50
innodb-flush-method = O_DIRECT
innodb-lru-scan-depth = 4000
innodb-checksum-algorithm = crc32
innodb-lock-wait-timeout = 10
innodb-rollback-on-timeout = 1
innodb-print-all-deadlocks = 1
innodb-file-per-table = 1
innodb-online-alter-log-max-size = 4G
innodb-stats-on-metadata = 0
default-storage-engine  = InnoDB

# some var for MySQL 8
log-error-verbosity = 3
innodb-print-ddl-logs = 1
binlog-expire-logs-seconds = 259200
#innodb-dedicated-server = 0

innodb-status-file = 1
innodb-status-output = 0
innodb-status-output-locks = 0

#performance-schema
performance-schema = 1
performance-schema-instrument = ‘%memory%=on‘
performance-schema-instrument = ‘%lock%=on‘

#innodb monitor
innodb-monitor-enable="module_innodb"
innodb-monitor-enable="module_server"
innodb-monitor-enable="module_dml"
innodb-monitor-enable="module_ddl"
innodb-monitor-enable="module_trx"
innodb-monitor-enable="module_os"
innodb-monitor-enable="module_purge"
innodb-monitor-enable="module_log"
innodb-monitor-enable="module_lock"
innodb-monitor-enable="module_buffer"
innodb-monitor-enable="module_index"
innodb-monitor-enable="module_ibuf_system"
innodb-monitor-enable="module_buffer_page"
innodb-monitor-enable="module_adaptive_hash"
#**************************federated********************
#federated

[mysqldump]
quick
max-allowed-packet = 2G
log-error=/apps/program/logs/mysqld/dump.log
net-buffer-length=8k

[mysqladmin]
default-character-set = utf8mb4
socket=/apps/program/tmp/mysql.sock

初始化数据库

/apps/program/mysql/bin/mysqld --initialize-insecure  --user=mysql
# 说明: --initialize-insecure 是初始化无需生成默认密码直接mysql 能进去不过记得一定要设置密码 --initialize 初始化设置默认密码
/apps/program/mysql/bin/mysqld --initialize  --user=mysql
#启动mysql
/etc/init.d/mysqld start
在/apps/program/logs/mysqld/error.log 查找密码
[[email protected] mysqld]# cat /apps/program/logs/mysqld/error.log | grep  [email protected]
2019-08-30T12:32:40.034868+08:00 5 [Note] [MY-010454] [Server] A temporary password is generated for [email protected]: h3zuqsQhPO&4
这个就是密码h3zuqsQhPO&4
这些密码必须修改不然任何事都不能做
修改密码:
alter user user()identified by"123456";
flush privileges;
关闭mysql
shutdown;
启动mysql
/etc/init.d/mysqld start
mysql -p
# 输入刚刚设置密码 即可登陆MySQL

mysql 创建用户

mysql 8.0 不能使用GRANT ALL PRIVILEGES ON *.* TO [email protected]‘%‘ IDENTIFIED BY ‘123456‘; FLUSH PRIVILEGES; 这样的方式创建账号密码

create user ‘root‘@‘%‘ identified by ‘123456‘;
flush privileges;
grant all privileges on *.* to ‘root‘@‘%‘;
flush privileges;

在远程使用Navicat  或者启动mysql 客户端工具进行连接
没意外的话就能正常登陆
mysql 8.0.17 源码编译安装完成

原文地址:https://blog.51cto.com/juestnow/2433913

时间: 2024-10-11 11:05:47

gcc 9.2.0 编译安装mysql 8.0.17的相关文章

CentOS 7.0编译安装Nginx1.6.0+MySQL5.6.19+PHP5.5.14

转载自http://www.osyunwei.com/archives/7891.html 准备篇: CentOS 7.0系统安装配置图解教程 http://www.osyunwei.com/archives/7829.html 一.配置防火墙,开启80端口.3306端口 CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙. 1.关闭firewall: systemctl stop firewalld.service #停止firewall systemc

CentOS 7.0编译安装Nginx1.6.0+MySQL5.6.19+PHP5.5.14方法分享

一.配置防火墙,开启80端口.3306端口CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙.1.关闭firewall: systemctl stop firewalld.service #停止firewall systemctl disable firewalld.service #禁止firewall开机启动 2.安装iptables防火墙 yum install iptables-services #安装 vi /etc/sysconfig/ipta

centos 7.0 编译 安装mysql 5.6.22 过程 未完成~~持续

mysql 下载目录/usr/local/srcmysql 解压目录 /usr/local/bin/mysql GitHub https://github.com/mysql/mysql-server mysql官网的安装说明http://dev.mysql.com/doc/refman/5.6/en/source-installation.html 安装mysql必须的要求 CMake make3.75以上 GCC 4.2.1以上 PerlCurses ncurses-devel 最新3.1.

CentOS 7.0编译安装Nginx+MySQL+PHP

转自http://www.centoscn.com/CentosServer/www/2014/0904/3673.html 准备篇: CentOS 7.0系统安装配置图解教程 http://www.centoscn.com/image-text/setup/2014/0724/3342.html 一.配置防火墙,开启80端口.3306端口 CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙. 1.关闭firewall: systemctl stop fi

Centos 7.0 编译安装LNMP(Linxu+nginx+mysql+php)之源码安装nginx (一)

nginx简介:       Nginx (engine x) 是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP服务器.Nginx是由伊戈尔·赛索耶夫为俄罗斯访问量第二的Rambler.ru站点(俄文:Рамблер)开发的,第一个公开版本0.1.0发布于2004年10月4日. 其将源代码以类BSD许可证的形式发布,因它的稳定性.丰富的功能集.示例配置文件和低系统资源的消耗而闻名.2011年6月1日,nginx 1.0.4发布. Nginx是一款轻量级的Web 服务器

Centos 7.0 编译安装LAMP(Linxu+apache+mysql+php)之源码安装Mysql (二)

mysql 简介: MySQL是一个关系型数据库管理系统,关系数据库将数据保存在不同的表中,这样就增加了速度并提高了灵活性.目前其属于 Oracle 旗下产品.MySQL 是最流行的关系型数据库管理系统之一,在 WEB 应用方面,MySQL是最好的 RDBMS (Relational Database Management System,关系数据库管理系统) 应用软件.MySQL所使用的 SQL 语言是用于访问数据库的最常用标准化语言. 安装环境: 系统: centos 7.0 最小化安装 软件

Centos 7.0 编译安装LAMP(Linxu+apache+mysql+php)之源码安装php (三)

PHP简介: PHP(外文名:PHP: Hypertext Preprocessor,中文名:"超文本预处理器")是一种通用开源脚本语言.语法吸收了C语言.Java和Perl的特点,利于学习,使用广泛,主要适用于Web开发领域.PHP 独特的语法混合了C.Java.Perl以及PHP自创的语法.它可以比CGI或者Perl更快速地执行动态网页.用PHP做出的动态页面与其他的编程语言相比,PHP是将程序嵌入到HTML(标准通用标记语言下的一个应用)文档中去执行,执行效率比完全生成HTML标

CentOS 6.5最小化编译安装mysql 5.5.35

1.关闭防火墙: [[email protected] ~]# service iptables stop iptables: Setting chains to policy ACCEPT: filter          [  OK  ] iptables: Flushing firewall rules:                         [  OK  ] iptables: Unloading modules:                               [

CentOS 6.5最小化编译安装mysql 5.5.35配置多实例

1.关闭防火墙 [[email protected] ~]# service iptables stop iptables: Setting chains to policy ACCEPT: filter          [  OK  ] iptables: Flushing firewall rules:                         [  OK  ] iptables: Unloading modules:                               [