MySQL8 安装(基于devtoolset-8)

MySQL8 安装(基于devtoolset-8)

环境:

系统:CentOS 7.6

MySQL: 8.0.16

注意:MySQL 8.0.16安装基于gcc 5.3.0以上版本,而CentOS 7.6的gcc版本为4.8.5,本次安装时基于devtoolset-8

Centos默认安装mariadb,需要先卸载:

[root@wxlun2206 mysql]# rpm -aq|grep mariadb
mariadb-libs-5.5.60-1.el7_5.x86_64
[root@wxlun2206 mysql]# rpm -e mariadb-libs-5.5.60-1.el7_5.x86_64

错误:依赖检测失败:

    libmysqlclient.so.18()(64bit) 被 (已安裝) postfix-2:2.10.1-6.el7.x86_64 需要

    libmysqlclient.so.18(libmysqlclient_18)(64bit) 被 (已安裝) postfix-2:2.10.1-6.el7.x86_64 需要

[root@wxlun2206 mysql]# rpm -e mariadb-libs-5.5.60-1.el7_5.x86_64 --nodeps
[root@wxlun2207 mysql]# rpm -aq|grep mariadb

yum -y install lrzsz gcc gcc-c++ htop lsof iotop tree unzip vim libunwind bison zlib zlib-devel libxml libxml-devel ncurses-devel ncurses gperftools openssl openssl-devel gmock gmock-devel glib2 glib2-devel pcre pcre-devel wget

echo “nameserver 114.114.114.114” >> /etc/resolv.conf

–CMake 3.4.3 or higher is required

cmake --version —如果低于3.4.3,卸载

yum remove cmake -y
 
cd /usr/local/src/
wget https://github.com/Kitware/CMake/releases/download/v3.14.3/cmake-3.14.3.tar.gz
tar zxf cmake-3.14.3.tar.gz
cd cmake-3.14.3
./bootstrap
make && make install

#–GCC 5.3 or newer is required,而CentOS 7 GCC版本为4.8.5

安装devtoolset-8,提供满足条件的GCC

yum -y install centos-release-scl
yum -y install devtoolset-8
scl enable devtoolset-8 -- bash

启用devtoolset-8:

source /opt/rh/devtoolset-8/enable

[root@ZB-2-50 ~]# gcc --version
gcc (GCC) 8.2.1 20180905 (Red Hat 8.2.1-3)
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
[root@ZB-2-50 ~]# g++ --version
g++ (GCC) 8.2.1 20180905 (Red Hat 8.2.1-3)
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

如果每次都需要devtoolset-8, .bash_profile添加:

source /opt/rh/devtoolset-8/enable

创建mysql用户

groupadd mysql
useradd -r -g mysql -s /bin/false mysql

上传mysql镜像(或自行下载)

tar zxf mysql-boost-8.0.16.tar.gz
cd mysql-8.0.16/

cmake  -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/data/mysql/data \
-DSYSCONFDIR=/data/mysql \
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=all \
-DWITH_EMBEDDED_SERVER=0 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_USER=mysql \
-DWITH_DEBUG=0 \
-DWITH_BOOST=./boost \
-DFORCE_INSOURCE_BUILD=1 \
-DUSE_LD_LLD=OFF

make && make install

mkdir /data/mysql/{data,log/{binlog,slow,relaylog}} -p
touch /data/mysql/log/mysql_error.log
mkdir /var/lib/mysql
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
sed -i '$a PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH' /etc/profile
sed -i '$a export PATH' /etc/profile
source  /etc/profile
cd /data/mysql

编辑my.cnf —略

chown -R mysql:mysql /data/mysql* /var/lib/mysql
/usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/data/mysql/data --basedir=/usr/local/mysql --port=3306
/usr/local/mysql/bin/mysqld_safe --user=mysql &
grep "A temporary password" /data/mysql/log/mysql_error.log ---查看临时root密码

root@wxlun04 mysql]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.16
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 databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> alter  user 'root'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)
mysql>

完成
原文出处:https://blog.csdn.net/wxl1314920/article/details/91039753

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值