centos7安装mysql5.7.26
时间: 2023-10-21 07:04:46 浏览: 89
centos7安装mysql5.7
以下是CentOS 7上安装MySQL 5.7.26的步骤:
1. 确认是否已经安装MySQL
```
sudo systemctl status mysqld
```
如果MySQL已经安装,则会显示MySQL的状态信息。
2. 安装MySQL源
```
sudo rpm -Uvh https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
```
3. 安装MySQL
```
sudo yum install mysql-community-server
```
4. 启动MySQL服务
```
sudo systemctl start mysqld
```
5. 查看MySQL状态
```
sudo systemctl status mysqld
```
如果MySQL成功启动,则会显示“active (running)”状态。
6. 设置MySQL自启动
```
sudo systemctl enable mysqld
```
7. 获取MySQL初始密码
```
sudo grep 'temporary password' /var/log/mysqld.log
```
8. 使用初始密码登录MySQL
```
mysql -u root -p
```
9. 修改密码,输入以下命令:
```
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
```
将new_password替换为新密码。
10. 退出MySQL
```
exit
```
这样你就可以在CentOS 7上成功安装了MySQL 5.7.26。
阅读全文