centos7安装mysql8.0
时间: 2023-09-12 11:13:24 浏览: 80
CentOS7安装MySQL8.0图文教程
5星 · 资源好评率100%
1. 添加MySQL 8.0的yum源
```
wget https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
yum localinstall mysql80-community-release-el7-1.noarch.rpm
```
2. 安装MySQL 8.0
```
yum install mysql-community-server
```
3. 启动MySQL服务
```
systemctl start mysqld
```
4. 查看MySQL服务状态
```
systemctl status mysqld
```
5. 设置MySQL服务开机自启
```
systemctl enable mysqld
```
6. 获取MySQL默认密码
```
grep 'temporary password' /var/log/mysqld.log
```
7. 登录MySQL
```
mysql -u root -p
```
8. 修改MySQL密码
```
ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码';
```
9. 修改MySQL配置文件
```
vi /etc/my.cnf
```
在[mysqld]下添加以下内容,设置默认字符集为utf8mb4
```
character-set-server=utf8mb4
default_authentication_plugin=mysql_native_password
```
10. 重启MySQL服务
```
systemctl restart mysqld
```
阅读全文