一、下载
https://downloads.mysql.com/archives/community/
“Source Code”>“Generic Linux (Architecture Independent)”>“Compressed TAR Archive”
二、安装
yum install -y cmake gcc gcc-c++ openssl openssl-devel ncurses ncurses-devel libtirpc-devel bison
wget https://nchc.dl.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz --no-check-certificate
tar -zxvf boost_1_59_0.tar.gz
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.32.tar.gz --no-check-certificate
tar -zxvf mysql-5.7.32.tar.gz
cd mysql-5.7.32/
#RHEL 8
#wget https://github.com/thkukuk/rpcsvc-proto/releases/download/v1.4/rpcsvc-proto-1.4.tar.gz
#tar -zxvf rpcsvc-proto-1.4.tar.gz
#cd rpcsvc-proto-1.4/ && ./configure && make && make install
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.7.32 -DMYSQL_DATADIR=/data/mysql-5.7.32/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_TCP_PORT=3306 -DMYSQL_USER=mysql -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DENABLE_DOWNLOADS=1 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/root/boost_1_59_0
make
#日志
#/root/mysql-5.7.32/include/my_atomic.h:72:4: error: #error Native atomics support not found!
# # error Native atomics support not found!
# ^
#解决 rm -f CMakeCache.txt
make install
三、启动
cat << "EOF" > /usr/lib/systemd/system/mysqld.service
[Unit]
Description=Mysql database server
After=syslog.target
After=network.target
[Service]
Type=simple
LimitNOFILE=655350
LimitMEMLOCK=655350
ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf
Restart=always
User=mysql
Group=mysql
[Install]
WantedBy=multi-user.target
EOF
ln -sf /usr/local/mysql-5.7.32 /usr/local/mysql
echo -e '\nexport PATH=/usr/local/mysql/bin:$PATH' >> ~/.bash_profile
groupadd mysql
useradd -r -g mysql -s /sbin/nologin mysql
mkdir -p /var/lib/mysql /data/mysql-5.7.32/data
chown -R mysql:mysql /var/lib/mysql /data/mysql-5.7.32
source ~/.bash_profile
mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql-5.7.32/data【记住密码】
cat <<"EOF">/etc/my.cnf
[mysqld]
socket=/var/lib/mysql/mysql.sock
symbolic-links=0
basedir = /usr/local/mysql
datadir = /data/mysql-5.7.32/data
port = 3306
server_id = 1
socket = /var/lib/mysql/mysql.sock
log-bin = /data/mysql-5.7.32/mysql-bin
binlog_format = mixed
expire-logs-days = 14
sync-binlog = 1
log-slave-updates = ON
slave-skip-errors = all
pid-file = /data/mysql-5.7.32/mysql.pid
character_set_server=utf8
slow_query_log=on
slow_query_log_file=/data/mysql-5.7.32/slow_query_log.log
long_query_time=2
log-error=/data/mysql-5.7.32/mysqld.log
innodb_file_per_table=1
innodb_fast_shutdown=0
innodb_buffer_pool_size = 8192M
skip-name-resolve
max_connections = 2000
max_user_connections = 200
open_files_limit = 655350
explicit_defaults_for_timestamp = 1
skip_slave_start
binlog-ignore-db = mysql,information_schema,performance_schema
log-slave-updates = ON
slave-skip-errors = all
replicate-ignore-db = mysql,information_schema,performance_schema
relay_log = /data/mysql-5.7.32/relay-bin
[mysql]
socket=/var/lib/mysql/mysql.sock
EOF
systemctl daemon-reload
systemctl enable mysqld
systemctl start mysqld
mysql -uroot -p【使用initialize密码登录】
set password for root@localhost = password('newpassword');