CentOS8.0使用RPM安装MySQL8.0.18

下载适用于CentOS8.0的MySQL8.0.18:

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

提示-bash: wget: command not found,这是因为没有安装wget,安装wget:

yum install wget

安装后重新下载,下载后解压缩:

tar xf mysql-8.0.18-1.el8.x86_64.rpm-bundle.tar

开始安装:

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

安装mysql-community-server-8.0.18-1.el8.x86_64.rpm时报错:

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

这是因为缺少依赖组件perl和net-tools,安装perl和net-tools:

yum install perl net-tools

然后重新安装mysql-community-server-8.0.18-1.el8.x86_64.rpm,安装后以空密码方式初始化MySQL:

mysqld --initialize-insecure

授予权限:

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

编辑my.cnf配置文件:

vi /etc/my.cnf

添加一行port=你要设置的端口号,修改MySQL的默认端口

socket=/var/lib/mysql/mysql.sock修改为socket=/dev/shm/mysql.sock

再添加以下两行:

[client]
socket=/dev/shm/mysql.sock

启动MySQL:

systemctl start mysqld.service

留下评论

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

回到顶部