centos8如何安装mysql5.7.31
时间: 2023-11-27 12:05:24 浏览: 32
centos7二进制安装MySQL5.7.docx
以下是在CentOS 8上安装MySQL 5.7.31的步骤:
1. 更新系统:
```
sudo yum update
```
2. 添加MySQL Yum存储库:
```
sudo rpm -Uvh https://dev.mysql.com/get/mysql57-community-release-el8-11.noarch.rpm
```
3. 安装MySQL 5.7.31:
```
sudo yum install mysql-community-server
```
4. 启动MySQL服务:
```
sudo systemctl start mysqld
```
5. 设置MySQL开机自启:
```
sudo systemctl enable mysqld
```
6. 查看MySQL服务状态:
```
sudo systemctl status mysqld
```
7. 登录MySQL:
```
sudo mysql -u root -p
```
8. 更改root用户密码:
```
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
```
9. 创建新用户并授权:
```
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'newuser'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
```
10. 退出MySQL:
```
exit
```
现在,你已经成功安装了MySQL 5.7.31,并且可以通过新用户登录MySQL。
阅读全文