Mysql8.0.18如何属性源码编译安装和gcc-9.2.0升级
这篇文章将为大家详细讲解有关Mysql8.0.18如何属性源码编译安装和gcc-9.2.0升级,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。
1、环境设置
[root@centos1opt]#vim/etc/selinux/configSELINUX=disabled
2、用户新增目录设置
[root@centos1opt]#idmysqlid:mysql:nosuchuser[root@centos1opt]#groupadd-g101mysql[root@centos1opt]#useradd-u514-gmysql-Groot-d/home/mysql-mmysql[root@centos1opt]#passwdmysqlChangingpasswordforusermysql.Newpassword:Retypenewpassword:passwd:allauthenticationtokensupdatedsuccessfully.[root@centos1opt]#idmysqluid=514(mysql)gid=101(mysql)groups=101(mysql),0(root)[root@centos1opt]#mkdir-p/usr/local/mysql[root@centos1opt]#chown-Rmysql.mysql/usr/local/mysql[root@centos1opt]#su-mysqlLastlogin:FriOct2516:18:20CST2019onpts/0[mysql@centos1~]$vi.bash_profilePATH=$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@centos1local]#chown-R755/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->mpccd/usr/local/src/编译:gmp-6.1.2tar-xvfgmp-6.1.2.tar.xzcdgmp-6.1.2./configure--prefix=/usr/local/gmp-6.1.2make-j$(nproc)makeinstallcd../编译:mpfr-4.0.2tar-xvfmpfr-4.0.2.tar.gzcdmpfr-4.0.2./configure--prefix=/usr/local/mpfr-4.0.2--with-gmp=/usr/local/gmp-6.1.2make-j$(nproc)makeinstallcd../编译:mpc-1.1.0tar-xvfmpc-1.1.0.tar.gzcdmpc-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.2make-j$(nproc)makeinstall#把mpfrlib加入ld.so.conf不然gcc编译报错echo/usr/local/mpfr-4.0.2/lib>>/etc/ld.so.confldconfig
编译安装gcc
cd/usr/local/src/tar-xvfgcc-9.2.0.tar.gzcdgcc-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-64make-j$(nproc)makeinstall-j$(nproc)##备份旧gcc可执行文件mv/usr/bin/gcc/usr/bin/gcc.oldmv/usr/bin/g++/usr/bin/g++.oldmv/usr/bin/c++/usr/bin/c++.oldmv/usr/bin/cpp/usr/bin/cpp.oldmv/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.pyecho/usr/local/gcc-9.2.0/lib64>>/etc/ld.so.confldconfig##复制libstdc++.so.6.0.27/lib64/cp/usr/local/gcc-9.2.0/lib64/libstdc++.so.6.0.27/lib64/#创建软链libstdc++.so.6cd/lib64ln-sflibstdc++.so.6.0.27libstdc++.so.6##查看是否最新版本strings/usr/lib64/libstdc++.so.6|grepGLIBCXX
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="nancyedition"\-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--Configuringdone--GeneratingdoneCMakeWarning:Manually-specifiedvariableswerenotusedbytheproject:EXTRA_CHARSETS--Buildfileshavebeenwrittento:/opt/mysql8
同目录下执行安装创建目录:
gmake-j$(nproc)gmakeinstall-j$(nproc)编译成功:Scanningdependenciesoftargetmysqld[100%]BuildingCXXobjectsql/CMakeFiles/mysqld.dir/main.cc.oScanningdependenciesoftargetpfs_connect_attr-t[100%]LinkingCXXexecutable../runtime_output_directory/mysqld[100%]BuildingCXXobjectstorage/perfschema/unittest/CMakeFiles/pfs_connect_attr-t.dir/pfs_connect_attr-t.cc.o[100%]BuildingCXXobjectstorage/perfschema/unittest/CMakeFiles/pfs_connect_attr-t.dir/__/__/__/sql/sql_builtin.cc.o[100%]LinkingCXXexecutable../../../runtime_output_directory/pfs_connect_attr-t[100%]Builttargetmysqld[100%]Builttargetpfs_connect_attr-t[root@centos1mysql8]#
查看目录:
[root@centos1mysql]#lltotal932drwxr-xr-x2rootroot4096Oct3014:54bindrwxr-xr-x2rootroot86Oct3014:54docsdrwxr-xr-x3rootroot282Oct3014:53includedrwxr-xr-x6rootroot4096Oct3014:54lib-rw-r--r--1rootroot408918Sep2016:30LICENSE-rw-r--r--1rootroot102977Sep2016:30LICENSE.router-rw-r--r--1rootroot408918Sep2016:30LICENSE-testdrwxr-xr-x4rootroot30Oct3014:54mandrwxr-xr-x10rootroot4096Oct3014:54mysql-test-rw-r--r--1rootroot687Sep2016:30README-rw-r--r--1rootroot700Sep2016:30README.router-rw-r--r--1rootroot687Sep2016:30README-testdrwxrwxr-x2rootroot6Oct3014:54rundrwxr-xr-x28rootroot4096Oct3014:54sharedrwxr-xr-x2rootroot77Oct3014:54support-filesdrwxr-xr-x3rootroot17Oct3014:54var
7、设置Mysql用户系统参数
[root@localhostcmake-3.0.1]#vi/etc/security/limits.confmysqlsoftnproc65536mysqlhardnproc65536mysqlsoftnofile65536mysqlhardnofile65536
8、配置启动文件
[root@centos1support-files]#echoexportPATH=$PATH:/usr/local/mysql/bin>>/etc/profile[root@centos1support-files]#echo/usr/local/mysql/lib>>/etc/ld.so.conf[root@centos1support-files]#ldconfig
# 复制启动文件
[root@centos1support-files]#cpmysql.server/etc/init.d/mysqld[root@centos1support-files]#chmod700/etc/init.d/mysqld[mysql@centos1mysql]$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升级”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。