Centos7 Yum安装MYSQL8.0详细安装步骤

Centos7 Yum安装MYSQL8.0详细安装步骤

精选文章moguli202025-05-13 22:41:258A+A-

### 0、更换yum源

1、打开 mirrors.aliyun.com,选择centos的系统,点击帮助

2、执行命令:yum install wget -y

3、改变某些文件的名称

```

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

```

4、执行更换yum源的命令

```

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

```

5、更新本地缓存

yum clean all

yum makecache

### 1、查看系统中是否自带安装mysql

```shell

yum list installed | grep mysql

```

### 2、删除系统自带的mysql及其依赖(防止冲突)

```shell

yum -y remove mysql-libs.x86_64

```

### 3、安装wget命令

```

yum install wget -y

```

### 4、给CentOS添加rpm源,并且选择较新的源

```

wget -i -c https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm

```

### 5、安装下载好的rpm文件

```

yum install mysql80-community-release-el7-3.noarch.rpm -y

```

### 6、使用yum安装mysql

```

yum install mysql-community-server -y

```

### 7、启动mysql服务

#启动mysql服务,查看启动状态及是否开机启动

```

systemctl start mysqld.service

systemctl status mysqld.service

systemctl list-unit-files | grep enabled

```

### 8、获取mysql的临时密码

```shell

grep "password" /var/log/mysqld.log

```

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(
img-RUVVjkiX-1627025241720)(E:\lian\oracle\typora-user-images\1570604493708.png)]

### 9、使用临时密码登录

```shell

mysql -uroot -p

#输入密码

```

### 10、修改密码

```sql

#密码要符合mysql安全规则,否则修改不成功

ALTER USER 'root'@'localhost' IDENTIFIED BY '密码';

```

### 11、修改远程访问权限

```sql

grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;

flush privileges;

```

### 12、设置字符集为utf-8

```shell

#在[mysqld]部分添加:

character-set-server=utf8

#在文件末尾新增[client]段,并在[client]段添加:

default-character-set=utf8

点击这里复制本文地址 以上内容由莫古技术网整理呈现,请务必在转载分享时注明本文地址!如对内容有疑问,请联系我们,谢谢!
qrcode

莫古技术网 © All Rights Reserved.  滇ICP备2024046894号-2