Centos 8.2 源码编译安装MySQL5.7.39

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

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值