Mysql8.0.18如何属性源码编译安装和gcc-9.2.0升级

这篇文章将为大家详细讲解有关MySQL8.0.18如何属性源码编译安装和gcc-9.2.0升级,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

专业成都网站建设公司,做排名好的好网站,排在同行前面,为您带来客户和效益!成都创新互联为您提供成都网站建设,五站合一网站设计制作,服务好的网站设计公司,网站设计、成都网站建设负责任的成都网站制作公司!

1、环境设置

[root@centos1 opt]# vim /etc/selinux/config
SELINUX=disabled

2、用户新增目录设置

[root@centos1 opt]# id mysqlid: mysql: no such user
[root@centos1 opt]#  groupadd -g 101 mysql
[root@centos1 opt]# useradd -u 514 -g mysql -G root -d /home/mysql  -m mysql
[root@centos1 opt]# passwd mysqlChanging password for user mysql.New password:
Retype new password: passwd: all authentication tokens updated successfully.
[root@centos1 opt]# id mysqluid=514(mysql) gid=101(mysql) groups=101(mysql),0(root)
[root@centos1 opt]# mkdir -p /usr/local/mysql
[root@centos1 opt]# chown -R mysql.mysql /usr/local/mysql
[root@centos1 opt]# su - mysql Last login: Fri Oct 25 16:18:20 CST 2019 on pts/0
[mysql@centos1 ~]$ vi .bash_profile
PATH=$PATH:$HOME/.local/bin:$HOME/bin:/usr/local/mysql
[root@centos1 ~]# mkdir -p /data/mysql/data
[root@centos1 ~]# mkdir -p /data/mysql/log
[root@centos1 ~]# mkdir -p /data/mysql/rum
[root@centos1 ~]# mv /data/mysql/rum /data/mysql/run
[root@centos1 ~]# mkdir -p /data/mysql/tmp
[root@centos1 local]# chown -R 755 /usr/local/mysql

3、解压安装包mysql-8.0.18.tar.gz  到 /opt/mysql8

4、安装依赖
yum install -y gcc gcc-c++ ncurses-devel bison zlib libxml openssl
更新cmake3 通过Yum 安装
yum install cmake3

安装后发现编译不通过 需要更新gcc版本5 以上

5、gcc-9.2.0编译安装

转载: https://www.2cto.com/net/201908/815589.html

安装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

6、cmake编译mysql

(由于装了不同的版本gcc,编译时可以通过参数指定版本****重要!*****)

cmake3 \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql/ \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=all \
-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 \
-DCOMPILATION_COMMENT="nancy edition" \
-DDOWNLOAD_BOOST=1 \
-DWITH_BOOST=/data/mysql/tmp \
-DMYSQL_UNIX_ADDR=/data/mysql/run/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DSYSCONFDIR=/data/mysql \
-DWITH_READLINE=1 \
-DFORCE_INSOURCE_BUILD=1 \
-DWITH_SSL=system \
-DWITH_ZLIB=system \
-DCMAKE_CXX_COMPILER=/usr/local/gcc-9.2.0/bin/g++ \
-DCMAKE_C_COMPILER=/usr/local/gcc-9.2.0/bin/gcc

编译结束:

-- CMAKE_EXE_LINKER_FLAGS -- CMAKE_MODULE_LINKER_FLAGS -- CMAKE_SHARED_LINKER_FLAGS -- Configuring done-- Generating doneCMake Warning:  Manually-specified variables were not used by the project:
    EXTRA_CHARSETS
-- Build files have been written to: /opt/mysql8

同目录下执行安装创建目录:

gmake -j $(nproc)gmake install -j $(nproc)
编译成功:
Scanning dependencies of target mysqld[100%] Building CXX object sql/CMakeFiles/mysqld.dir/main.cc.oScanning dependencies of target pfs_connect_attr-t[100%] Linking CXX executable ../runtime_output_directory/mysqld[100%] Building CXX object storage/perfschema/unittest/CMakeFiles/pfs_connect_attr-t.dir/pfs_connect_attr-t.cc.o[100%] Building CXX object storage/perfschema/unittest/CMakeFiles/pfs_connect_attr-t.dir/__/__/__/sql/sql_builtin.cc.o[100%] Linking CXX executable ../../../runtime_output_directory/pfs_connect_attr-t[100%] Built target mysqld[100%] Built target pfs_connect_attr-t[root@centos1 mysql8]#

查看目录:

[root@centos1 mysql]# ll
total 932
drwxr-xr-x  2 root root   4096 Oct 30 14:54 bin
drwxr-xr-x  2 root root     86 Oct 30 14:54 docs
drwxr-xr-x  3 root root    282 Oct 30 14:53 include
drwxr-xr-x  6 root root   4096 Oct 30 14:54 lib
-rw-r--r--  1 root root 408918 Sep 20 16:30 LICENSE
-rw-r--r--  1 root root 102977 Sep 20 16:30 LICENSE.router
-rw-r--r--  1 root root 408918 Sep 20 16:30 LICENSE-test
drwxr-xr-x  4 root root     30 Oct 30 14:54 man
drwxr-xr-x 10 root root   4096 Oct 30 14:54 mysql-test
-rw-r--r--  1 root root    687 Sep 20 16:30 README
-rw-r--r--  1 root root    700 Sep 20 16:30 README.router
-rw-r--r--  1 root root    687 Sep 20 16:30 README-test
drwxrwxr-x  2 root root      6 Oct 30 14:54 run
drwxr-xr-x 28 root root   4096 Oct 30 14:54 share
drwxr-xr-x  2 root root     77 Oct 30 14:54 support-files
drwxr-xr-x  3 root root     17 Oct 30 14:54 var

7、设置Mysql用户系统参数

[root@localhost cmake-3.0.1]# vi /etc/security/limits.conf
mysql soft nproc 65536
mysql hard nproc 65536
mysql soft nofile 65536
mysql hard nofile 65536

8、配置启动文件

[root@centos1 support-files]# echo export PATH=$PATH:/usr/local/mysql/bin >>/etc/profile
[root@centos1 support-files]# echo /usr/local/mysql/lib >> /etc/ld.so.conf
[root@centos1 support-files]# ldconfig

# 复制启动文件

[root@centos1 support-files]# cp mysql.server  /etc/init.d/mysqld
[root@centos1 support-files]# chmod 700 /etc/init.d/mysqld
[mysql@centos1 mysql]$ vi /data/mysql/my.cnf

[client]
port = 3306
socket = /data/mysql/run/mysql.sock
# The MySQL server
[mysqld]
port = 3306
user = mysql
socket = /data/mysql/run/mysql.sock
pid_file = /data/mysql/mysqld.pid
basedir = /usr/local/mysql
datadir = /data/mysql/data
tmpdir = /data/mysql/tmp
open_files_limit = 65535
explicit_defaults_for_timestamp
server_id = 1
lower_case_table_names = 1
character_set_server = utf8
#sql_mode=STRICT_TRANS_TABLES
#
# ******security
safe_user_create
max_connections = 3000
max_user_connections=2980
secure_file_priv=/data/mysql/tmp

max_connect_errors = 100000
interactive_timeout = 86400
wait_timeout = 86400
sync_binlog=100
back_log=1024
max_binlog_cache_size=2147483648
max_binlog_size=524288000
default_storage_engine = InnoDB
log_slave_updates = 1

#*********** Logs related settings ***********
log_bin = /data/mysql/binlog/mysql-bin
[mysql@centos1 mysql]$ more /date/mysql/my.cnf
/date/mysql/my.cnf: No such file or directory
[mysql@centos1 mysql]$ more /data/mysql/my.cnf
[client]
port = 3306
socket = /data/mysql/run/mysql.sock
# The MySQL server
[mysqld]
port = 3306
user = mysql
socket = /data/mysql/run/mysql.sock
pid_file = /data/mysql/mysqld.pid
basedir = /usr/local/mysql
datadir = /data/mysql/data
tmpdir = /data/mysql/tmp
open_files_limit = 65535
explicit_defaults_for_timestamp
server_id = 1
lower_case_table_names = 1
character_set_server = utf8
#sql_mode=STRICT_TRANS_TABLES
#
# ******security
safe_user_create
max_connections = 3000
max_user_connections=2980
secure_file_priv=/data/mysql/tmp

max_connect_errors = 100000
interactive_timeout = 86400
wait_timeout = 86400
sync_binlog=100
back_log=1024
max_binlog_cache_size=2147483648
max_binlog_size=524288000
default_storage_engine = InnoDB
log_slave_updates = 1

#*********** Logs related settings ***********
log_bin = /data/mysql/binlog/mysql-bin
binlog_format= mixed
binlog_cache_size=32m
max_binlog_cache_size=64m
max_binlog_size=512m
long_query_time = 1
log_output = FILE
log_error = /data/mysql/mysql-error.log
slow_query_log = 1
slow_query_log_file = /data/mysql/slow_statement.log
log_queries_not_using_indexes=0
log_slave_updates=ON
log_slow_admin_statements=1
general_log = 0
general_log_file = /data/mysql/general_statement.log
binlog_expire_logs_seconds = 1728000
relay_log = /data/mysql/binlog/relay-bin
relay_log_index = /data/mysql/binlog/relay-bin.index
#****** MySQL Replication New Feature*********
master_info_repository=TABLE
relay-log-info-repository=TABLE
relay-log-recovery
#*********** INNODB Specific options ***********
innodb_buffer_pool_size = 4096M
transaction_isolation=REPEATABLE-READ
innodb_buffer_pool_instances = 8
innodb_file_per_table = 1
innodb_data_home_dir = /data/mysql/innodb_ts
innodb_data_file_path = ibdata1:2048M:autoextend
innodb_thread_concurrency = 8
innodb_log_buffer_size = 67108864
innodb_log_file_size = 1048576000
innodb_log_files_in_group = 4
innodb_max_undo_log_size=4G
innodb_undo_directory=/data/mysql/undo_space


innodb_log_group_home_dir = /data/mysql/innodb_log
innodb_adaptive_flushing=ON
innodb_flush_log_at_trx_commit = 2
innodb_max_dirty_pages_pct = 60
innodb_open_files=60000
innodb_purge_threads=1
innodb_read_io_threads=4
innodb_stats_on_metadata=OFF
innodb_flush_method=O_DIRECT
[mysql]
no-auto-rehash
default-character-set=UTF8MB4
#prompt = (\u@\h) [\d]>\_
net-buffer-length=64K
unbuffered
max-allowed-packet = 2G

#some var for mysql8
#log_error_verbosity=3
#innodb_print_ddl_logs=1
#binlog_expire_logs_seconds=259200
#innodb_dedicate_server=0
#
#innodb_status_file=1
#innodb_status_output=0
#innodb_status_output_locks=0

[mysqldump]
quick
max_allowed_packet=2G
log_error=/data/mysql/log/mysqld/dump.log
net_buffer_length=8k


9、初始化

$/usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/my.cnf --initialize --user=mysql

查看初始化日志及密码

[mysql@centos1 mysql]$ vi mysql-error.log

2019-10-31T03:30:00.222973Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: j63rKGLr3j-L

10、启动mysql服务
$/usr/local/mysql/bin/mysqld_safe --defaults-file=/data/mysql/my.cnf --user=mysql &

登录

[mysql@centos1 bin]$ mysql -uroot -pj63rKGLr3j-L
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.18

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show variable

ALTER USER 'root'@'localhost' IDENTIFIED WITH sha256_password BY 'mysqlWAI' PASSWORD EXPIRE INTERVAL 360 DAY;


关闭数据库
[mysql@centos1 bin]$ mysqladmin -uroot -pmysqlWAI --socket=/data/mysql/run/mysql.sock shutdown &

完成!

关于“Mysql8.0.18如何属性源码编译安装和gcc-9.2.0升级”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。


网站栏目:Mysql8.0.18如何属性源码编译安装和gcc-9.2.0升级
转载源于:http://bzwzjz.com/article/gecdes.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 成都网站设计 成都网站建设公司 企业网站设计 外贸网站设计方案 响应式网站设计方案 成都企业网站建设 手机网站制作 成都网站设计 营销网站建设 成都网站建设 成都h5网站建设 品牌网站建设 移动网站建设 成都网站建设公司 成都网站建设公司 定制网站制作 重庆企业网站建设 网站设计公司 自适应网站建设 成都网站建设推广 成都网站建设 成都网站设计制作公司