使用centos7安装mysql8.0,怎么安装
时间: 2024-01-25 20:01:48 浏览: 82
以下是在 CentOS 7 上安装 MySQL 8.0 的步骤:
1. 添加 MySQL 官方 Yum 源
```shell
sudo rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
```
2. 安装 MySQL
```shell
sudo yum install mysql-server
```
3. 启动 MySQL
```shell
sudo systemctl start mysqld
```
4. 设置 MySQL 开机自启
```shell
sudo systemctl enable mysqld
```
5. 修改 root 用户密码
```shell
sudo grep 'temporary password' /var/log/mysqld.log
mysql_secure_installation
```
按照提示设置 root 用户密码,可以选择关闭不必要的功能。
6. 登录 MySQL
```shell
mysql -u root -p
```
7. 修改密码策略
如果需要修改密码策略,可以执行以下命令:
```sql
SET GLOBAL validate_password.policy=LOW;
SET GLOBAL validate_password.length=4;
```
这里设置密码长度为 4,密码策略为 LOW。
以上是在 CentOS 7 上安装 MySQL 8.0 的步骤。
相关问题
centos7安装MySQL8.0
安装MySQL8.0的步骤如下:
1. 添加MySQL Yum Repository
```
$ sudo rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
```
2. 安装MySQL Server
```
$ sudo yum install mysql-community-server
```
3. 启动MySQL服务
```
$ sudo systemctl start mysqld
```
4. 查看MySQL服务状态
```
$ sudo systemctl status mysqld
```
5. 设置MySQL开机自启
```
$ sudo systemctl enable mysqld
```
6. 获取初始密码
```
$ sudo grep 'temporary password' /var/log/mysqld.log
```
7. 登录MySQL并修改密码
```
$ mysql -u root -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
```
centos7安装mysql8.0
以下是CentOS 7上安装MySQL 8.0的步骤:
1. 下载MySQL的yum仓库rpm包:
```
$ wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
```
2. 安装MySQL的yum仓库rpm包:
```
$ sudo rpm -ivh mysql80-community-release-el7-3.noarch.rpm
```
3. 安装MySQL 8.0:
```
$ sudo yum install mysql-community-server
```
4. 启动MySQL服务:
```
$ sudo systemctl start mysqld
```
5. 获取MySQL初始密码:
```
$ sudo grep 'temporary password' /var/log/mysqld.log
```
6. 登录MySQL并修改密码:
```
$ mysql -u root -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
```
7. (可选)设置MySQL开机自启动:
```
$ sudo systemctl enable mysqld
```
现在,您已经成功安装了MySQL 8.0,并且可以使用新密码登录MySQL。
阅读全文