Centos7 离线安装和配置mysql8

环境信息

系统: centos7

数据库: MySql 8.0.21

环境信息

资源信息版本备注
服务器Centos7使用的虚拟机
数据库MySql 8.0.21使用的 *rpm 安装方式

1 下载离线安装包

官网地址:https://downloads.mysql.com/archives/community/

CSDN 下载地址: https://download.csdn.net/download/qq_15769939/14504214

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-IIkEkWMM-1619339949985)(Centos7 离线安装和配置mysql8.assets/mysql离线安装包下载.png)]

2 上传文件到服务器

可以用ftp工具,这里我使用命令进行文件上传,上传目录到 /opt/software/ 目录不存在需自己创建

1:输入rz命令,看是否已经安装了lrzsz,如果没有安装则执行 yum -y install lrzsz命令进行安装。

[root@localhost ~]# rz
-bash: rz: command not found
[root@localhost ~]# yum -y install lrzsz

2:安装成功后查看是否安装成功

[root@localhost ~]# rpm -qa lrzsz
lrzsz-0.12.20-36.el7.x86_64

3:输入rz -y 进行上传

在这里插入图片描述

3 解压文件到指定位置

当前演示解压到/opt/module/mysql下,目录不存在需自己创建

[root@localhost ~]# cd /opt/software/
[root@localhost module]# tar -xvf mysql-8.0.21-1.el7.x86_64.rpm-bundle.tar  -C /opt/module/mysql
[root@localhost ~]# cd /opt/module/mysql

4 执行安装命令

[root@localhost mysql]# yum localinstall *.rpm

执行过程中会自动处理依赖关系

5 启动服务

[root@localhost mysql]# systemctl start mysqld

6 安装与配置

6.1 修改默认密码

6.1.1 查看默认密码

[root@localhost ~]# cat /var/log/mysqld.log | grep "A temporary password"
2021-01-15T06:46:57.734199Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: xQ4bCD)6Im1p

6.1.2 修改密码

[root@localhost ~]# mysql_secure_installation 

输入随机密码,然后确认,再更改新的密码,再确认

6.2 修改密码验证方式

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.21 MySQL Community Server - GPL

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> SELECT Host, User, plugin from user;
+-----------+------------------+-----------------------+
| Host      | User             | plugin                |
+-----------+------------------+-----------------------+
| %         | root             | mysql_native_password |
| localhost | mysql.infoschema | caching_sha2_password |
| localhost | mysql.session    | caching_sha2_password |
| localhost | mysql.sys        | caching_sha2_password |
+-----------+------------------+-----------------------+
4 rows in set (0.00 sec)

mysql> ALTER USER root@localhost IDENTIFIED WITH mysql_native_password BY '123456';

mysql> FLUSH PRIVILEGES;

mysql> SELECT Host, User, plugin from user;
+-----------+------------------+-----------------------+
| Host      | User             | plugin                |
+-----------+------------------+-----------------------+
| %         | root             | mysql_native_password |
| localhost | mysql.infoschema | caching_sha2_password |
| localhost | mysql.session    | caching_sha2_password |
| localhost | mysql.sys        | caching_sha2_password |
+-----------+------------------+-----------------------+
4 rows in set (0.00 sec)

6.3 允许远程连接

mysql> use mysql;
mysql> mysql update user set host="%" where user="root";
mysql> flush privileges;

6.4 开放防火墙

[root@localhost ~]# firewall-cmd --zone=public --add-port=3306/tcp --permanent
[root@localhost ~]# firewall-cmd --reload

7 启动与测试

7.1 服务管理

7.1.1 启动mysql8

[root@localhost ~]# systemctl restart mysqld

7.1.2 停止mysql8

停止

 systemctl stop mysqld

重启

[root@localhost ~]# systemctl restart mysqld

7.2 访问测试

这里使用 navicat 连接测试

在这里插入图片描述

9 相关信息

  • 博文不易,辛苦各位猿友点个关注和赞,感谢
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小P聊技术

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值