Yum安装MySQL

Yum安装MySQL

环境准备

关闭防火墙

1
systemctl stop firewalld && systemctl disable firewalld
1
setenforce 0 && sed -i 's/SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config

安装常用软件

1
yum install -y wget  net-tools  bash-completion 

更新软件

1
yum update

使用yum源安装

下载mysql安装源

1
https://dev.mysql.com/downloads/repo/yum/

image-20230919092155207

根据系统版本点击Download

点击下载rpm包 或者右键复制链接

image-20230919092456556

1
wget https://dev.mysql.com/get/mysql80-community-release-el7-10.noarch.rpm
1
rpm -ivh mysql80-community-release-el7-10.noarch.rpm

image-20230919093121744

配置安装源

1
2
cd /etc/yum.repos.d/
vim mysql-community.repo

image-20230919093455820

根据需求版本号配置

image-20230919093759357

我这里直接装8.0 所以不需要修改

安装mysql

1
yum -y install mysql-community-server

image-20230919094404877

启动MySQL并设置开机自启

1
systemctl  start mysqld && systemctl  enable mysqld

修改mysql初始化密码及权限

1
grep password  /var/log/mysqld.log

image-20230919101925512

登录数据库

1
mysql -p'密码'   ##注意带特殊字符的必须要加单引号

配置密码及权限

1
2
3
4
alter user 'root'@'localhost' identified by 'Jianren@123';
grant all privileges on *.* to 'root'@'localhost' ;
flush privileges;
exit ;

image-20230919102313151

使用rpm包安装

下载mysql rpm 安装包 。选择对应的操作系统版本官网地址 下载对应的rpm包

上传并解压

1
tar xf mysql-8.0.20-1.el7.x86_64.rpm-bundle.tar

image-20230919141231077

安装

1
yum -y install *.rpm

image-20230919141315333

启动MySQL并设置开机自启

1
systemctl  start mysqld && systemctl  enable mysqld

修改mysql初始化密码及权限

1
grep password  /var/log/mysqld.log

image-20230919101925512

登录数据库

1
mysql -p'密码'   ##注意带特殊字符的必须要加单引号
1
2
3
4
alter user 'root'@'localhost' identified by 'Jianren@123';
grant all privileges on *.* to 'root'@'localhost' ;
flush privileges;
exit ;

image-20230919102313151


Yum安装MySQL
http://ziiix.cn/2024/11/08/Yum安装MySQL/
作者
John Doe
发布于
2024年11月8日
许可协议