本篇文章介绍怎么使用Yum指令安装MySQL数据库
1.更新yum
2.下载mysql的rpm包,也可以点击此链接链接,下载其他版本
1 2 3 4
| sudo wget https://repo.mysql.com/mysql80-community-release-el7-11.noarch.rpm sudo wget https://repo.mysql.com/mysql80-community-release-el8-7.noarch.rpm sudo wget https://repo.mysql.com/mysql80-community-release-el8-9.noarch.rpm
|
3.升级和更新rpm包
1 2 3 4
| sudo rpm -Uvh mysql80-community-release-el8-7.noarch.rpm sudo rpm -Uvh mysql80-community-release-el8-9.noarch.rpm sudo rpm -Uvh mysql80-community-release-el7-11.noarch.rpm
|
4.安装依赖
1 2 3
| yum -y install wget cmake gcc gcc-c++ ncurses ncurses-devel libaio-devel openssl openssl-devel rpm -qa |grep libaio yum install libaio libaio-devel
|
5.安装Mysql
1
| sudo yum install mysql-server
|
6.运行MySQL和配置开机自启
1 2 3 4 5 6
| sudo systemctl start mysqld
sudo systemctl status mysqld
sudo systemctl enable mysqld
|
7. 配置MySQL 8.0
7.1.修改root密码,运行以下命令
1
| sudo mysql_secure_installation
|
7.2.输入新密码,一路enter,然后输入密码即可
1 2 3
| The existing password for the user account root has expired. Please set a new password. New password:你的密码 Re-enter new password: 你的密码
|
7.3.登录验证