Centos8.5安装mysql5.7
时间: 2023-12-13 15:32:49 浏览: 189
centos系统安装mysql5.7
以下是在CentOS 8.5上安装MySQL 5.7的步骤:
1.下载MySQL 5.7的yum repository RPM包:
```shell
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
```
2.安装yum repository RPM包:
```shell
sudo yum localinstall mysql57-community-release-el7-8.noarch.rpm
```
3.安装MySQL 5.7:
```shell
sudo yum install mysql-community-server
```
4.启动MySQL服务:
```shell
sudo systemctl start mysqld
```
5.检查MySQL服务状态:
```shell
sudo systemctl status mysqld
```
6.设置MySQL服务开机自启动:
```shell
sudo systemctl enable mysqld
```
7.获取MySQL初始密码:
```shell
sudo grep 'temporary password' /var/log/mysqld.log
```
8.登录MySQL:
```shell
mysql -u root -p
```
9.输入初始密码,然后修改密码:
```mysql
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
```
注意:在第8步中,如果出现“Access denied for user 'root'@'localhost' (using password: YES)”的错误,可能是因为MySQL 5.7默认使用了caching_sha2_password插件,而不是mysql_native_password插件。可以通过以下步骤解决:
1.以root用户登录MySQL:
```shell
sudo mysql -u root
```
2.执行以下命令:
```mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
```
其中,password是你要设置的新密码。
阅读全文