yum -y update
yum -y install epel-release
yum -y group install "Development Tools"
yum -y install ncurses-devel openssl openssl-devel bison
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-boost-8.0.17.tar.gz
wget https://cmake.org/files/v3.17/cmake-3.17.0.tar.gz
tar -zxvf cmake-3.17.0.tar.gz
cd cmake-3.17.0
./bootstrap
gmake
make install
cmake --version
wget https://mirrors.ustc.edu.cn/gnu/gcc/gcc-9.2.0/gcc-9.2.0.tar.gz
tar -zxvf gcc-9.2.0.tar.gz
cd gcc-9.2.0
./contrib/download_prerequisites
./configure --prefix=/usr/local/gcc --enable-bootstrap --enable-checking=release --enable-languages=c,c++ --disable-multilib
time make -j4 //-j4的作用是利用多核,4代表4核cpu
make install –j4
mv /usr/bin/gcc /usr/bin/gcc.back
mv /usr/bin/g++ /usr/bin/g++.back
mv /usr/bin/c++ /usr/bin/c++.back
mv /usr/bin/cpp /usr/bin/cpp.back
mv /usr/bin/gcov /usr/bin/gcov.back
### 创建最新gcc 执行文件软链
ln -sf /usr/local/gcc/bin/* /usr/bin/
### 删除lib64 目录下.py 文件不然ldconfig 报错
rm -rf /usr/local/gcc/lib64/libstdc++.so.6.0.27-gdb.py
echo /usr/local/gcc/lib64 >> /etc/ld.so.conf
ldconfig
### 复制libstdc++.so.6.0.27 /lib64/
cp /usr/local/gcc/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
tar -zxvf mysql-boost-8.0.17.tar.gz
cd mysql-8.0.17/
useradd mysql
mkdir /data/mysql
chown -R mysql:mysql /data/mysql/
mkdir /usr/local/boost ###用来存放boost的
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/data/mysql \
-DSYSCONFDIR=/etc \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DENABLE_DTRACE=0 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EMBEDDED_SERVER=1 \
-DFORCE_INSOURCE_BUILD=1 \
-DDOWNLOAD_BOOST=1 \
-DWITH_BOOST=/usr/local/boost
make -j4
make install -j4
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
#添加开机自启动
chkconfig --add mysqld
chkconfig mysqld on
## 添加mysql 到环境变量
echo export PATH=$PATH:/usr/local/mysql/bin >>/etc/profile
source /etc/profile
vim /etc/my.cnf
#将所有内容删除后,添加以下内容
[client]
port=3306
socket=/tmp/mysql.sock
default-character-set=utf8
[mysqld]
server-id=1
port=3306
user=mysql
max_connections=512
socket=/tmp/mysql.sock
basedir=/usr/local/mysql
datadir=/data/mysql
pid-file=/data/mysql/mysql.pid
character-set-server=utf8mb4
default-storage-engine=INNODB
log_error=/data/mysql/error.log
slow_query_log_file=/data/mysql/mysql-slow.log
#默认密码加密方式,防止一些管理工具不支持caching_sha2_password
default-authentication-plugin=mysql_native_password
max_allowed_packet=32M
#开启binlog日志
log-bin=/data/mysql/mysql-bin
binlog_format=ROW
[mysqldump]
quick
max_allowed_packet=2G
mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql
## 启动数据库
service mysqld start
#连接mysql客户端,默认密码为空
mysql -uroot
#修改所有用户的密码:
alter user user() identified by "123456";
#添加用户
create user 'root'@'%' identified by '123456';
grant all privileges on *.* to 'root'@'%';
flush privileges;