centos7安装mysql8.0简书_Centos7 离线安装和配置mysql8

本文介绍了在CentOS7系统上离线安装MySQL8.0.21的步骤,包括下载安装包、上传到服务器、解压、安装、设置初始密码、修改默认验证方式、允许远程连接以及启动、暂停、重启服务的操作,并提到了开放防火墙3306端口的重要性。
摘要由CSDN通过智能技术生成

环境信息

系统: centos7

数据库: MySql 8.0.21

1 下载离线安装包

官网地址:

902493830866

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 进行上传

902493830866

文件上传.png

3 解压文件到指定位置

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

[root@localhost ~]# cd /opt/software/

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

[root@localhost ~]# cd /opt/module/mysql

4 执行安装命令

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

902493830866

处理依赖关系.png

902493830866

输入y.png

902493830866

安装完成.png

5 修改密码

5.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

5.2 修改MySQL密码

[root@localhost ~]# mysql_secure_installation

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

5.3 修改默认密码验证方式

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 允许远程连接

mysql> use mysql;

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

mysql> flush privileges;

7 服务管理

7.1 启动服务

[root@localhost ~]# systemctl start mysqld

7.2 暂停服务

[root@localhost ~]# systemctl stop mysqld

7.3 重启服务

[root@localhost ~]# systemctl restart mysqld

7.4 开放防火墙端口

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

[root@localhost ~]# firewall-cmd --reload

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值