CentOS使用RPM安装MySQL

下载 wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.20-1.el8.x86_64.rpm-bundle.tar

解压缩包 tar xf mysql-8.0.20-1.el8.x86_64.rpm-bundle.tar

安装

rpm -ivh mysql-community-common-8.0.20-1.el8.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.20-1.el8.x86_64.rpm
rpm -ivh mysql-community-client-8.0.20-1.el8.x86_64.rpm
rpm -ivh mysql-community-server-8.0.20-1.el8.x86_64.rpm

初始化 (root密码为空) mysqld --initialize-insecure

授权 chown mysql:mysql /var/lib/mysql -R

启动 systemctl start mysqld.service

安装过程中可能出现的报错以及解决办法

error: Failed dependencies:
/usr/bin/perl is needed by mysql-community-server-8.0.20-1.el8.x86_64
perl(Getopt::Long) is needed by mysql-community-server-8.0.20-1.el8.x86_64
perl(strict) is needed by mysql-community-server-8.0.20-1.el8.x86_64

解决办法:yum install perl

error: Failed dependencies:
net-tools is needed by mysql-community-server-8.0.20-1.el8.x86_64

解决办法:yum install net-tools

error: Failed dependencies:
libaio.so.1()(64bit) is needed by mysql-community-server-8.0.20-1.el7.x86_64
libaio.so.1(LIBAIO_0.1)(64bit) is needed by mysql-community-server-8.0.20-1.el7.x86_64
libaio.so.1(LIBAIO_0.4)(64bit) is needed by mysql-community-server-8.0.20-1.el7.x86_64

解决办法:yum install libaio

error: Failed dependencies:
mariadb-libs is obsoleted by mysql-community-libs-8.0.20-1.el7.x86_64

解决办法:

rpm -q mariadb-libs
rpm -e 上条命令的输出结果 --nodeps

Job for mysqld.service failed because the control process exited with error code.
See "systemctl status mysqld.service" and "journalctl -xe" for details.
错误日志显示:
[ERROR] [MY-012681] [InnoDB] mmap(137428992 bytes) failed; errno 12
[ERROR] [MY-012956] [InnoDB] Cannot allocate memory for the buffer pool
[ERROR] [MY-012930] [InnoDB] Plugin initialization aborted with error Generic error.
[ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine
[ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
[ERROR] [MY-010119] [Server] Aborting

解决办法:

1.增加服务器内存;
2.使用虚拟内存(SWAP分区):
fallocate -l 1024M /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo "/swapfile swap swap sw 0 0" >> /etc/fstab

发表评论

电子邮件地址不会被公开。 必填项已用*标注