yum -y install cmake make gcc gcc-c++ perl openssl-devel ncurses-devel libcurl-devel libaio-devel zlib-devel perl-Data-Dumper
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-boost-5.7.39.tar.gz
tar xf mysql-boost-5.7.39.tar.gz && cd mysql-5.7.39
cat > cmake.sh << 'EOF'
cmake . \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql/ \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DMYSQL_TCP_PORT=3306 \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
-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 \
-DENABLED_LOCAL_INFILE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8mb4 \
-DDEFAULT_COLLATION=utf8mb4_general_ci \
-DWITH_SSL=system \
-DWITH_BOOST=/root/mysql-5.7.39/boost \
-DDOWNLOAD_BOOST=1
EOF
chmod +x cmake.sh
./cmake.sh && make -j 8 && make install
useradd mysql -r -s /sbin/nologin
cd /usr/local/mysql
mkdir mysql-files
chown -R mysql.mysql /usr/local/mysql
rm -rf /etc/my.cnf
bin/mysqld --initialize --user=mysql 2>&1 | tee password.txt
bin/mysql_ssl_rsa_setup
ll /usr/local/mysql/data
cat > /usr/lib/systemd/system/mysqld.service << 'EOF'
[Unit]
Description=MySQL Server
After=network.target
After=syslog.target
[Service]
User=mysql
Group=mysql
Type=forking
PIDFile=/usr/local/mysql/mysqld.pid
TimeoutSec=0
PermissionsStartOnly=true
ExecStart=/usr/local/mysql/bin/mysqld --daemonize --pid-file=/usr/local/mysql/mysqld.pid $MYSQLD_OPTS
EnvironmentFile=-/etc/sysconfig/mysql
LimitNOFILE = 5000
Restart=on-failure
RestartPreventExitStatus=1
PrivateTmp=false
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl start mysqld
systemctl enable mysqld
echo 'export PATH=$PATH:/usr/local/mysql/bin' >> /etc/profile
source /etc/profile
# 获取临时密码
grep 'temporary password' /usr/local/mysql/password.txt
mysql_secure_installation
mysql -pAdmin@2022
# 开启root远程登录、访问
===
mysql> use mysql;
mysql> select host,user from user;
mysql> grant all privileges on *.* to 'root'@'%' identified by 'Admin@2022' with grant option;
mysql> flush privileges;
===
mysql -h 192.168.1.201 -P 3306 -pAdmin@2022
常见的错误及解决方法:
1. Package ‘libtirpc‘, required by ‘virtual:world‘, not found
-- Checking for module ‘libtirpc‘
-- Package ‘libtirpc‘, required by ‘virtual:world‘, not found
CMake Error at cmake/rpc.cmake:65 (MESSAGE):
Could not find rpc/rpc.h in /usr/include or /usr/include/tirpc
Call Stack (most recent call first):
plugin/group_replication/libmysqlgcs/configure.cmake:57 (MYSQL_CHECK_RPC)
plugin/group_replication/libmysqlgcs/CMakeLists.txt:28 (INCLUDE)
解决:
yum install -y libtirpc-devel
2.Could not find rpcgen
CMake Error at rapid/plugin/group_replication/rpcgen.cmake:93 (MESSAGE):
Could not find rpcgen
Call Stack (most recent call first):
rapid/plugin/group_replication/CMakeLists.txt:29 (INCLUDE)
解决:
wget https://github.com/thkukuk/rpcsvc-proto/releases/download/v1.4.1/rpcsvc-proto-1.4.1.tar.xz
xz -d rpcsvc-proto-1.4.1.tar.xz
tar -xvf rpcsvc-proto-1.4.1.tar
cd rpcsvc-proto-1.4.1
./configure
make
make install