【Centos】RPM安装Mysql8
先去官网下载RPM包,没想到RPM包是红帽发行版
https://dev.mysql.com/downloads/mysql/

使用wget直接下载到Centos里面:
wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.27-1.el7.x86_64.rpm-bundle.tar
解压Tar包:
[root@localhost ~]# tar -xvf mysql-8.0.27-1.el7.x86_64.rpm-bundle.tar
mysql-community-client-8.0.27-1.el7.x86_64.rpm
mysql-community-client-plugins-8.0.27-1.el7.x86_64.rpm
mysql-community-common-8.0.27-1.el7.x86_64.rpm
mysql-community-devel-8.0.27-1.el7.x86_64.rpm
mysql-community-embedded-compat-8.0.27-1.el7.x86_64.rpm
mysql-community-libs-8.0.27-1.el7.x86_64.rpm
mysql-community-libs-compat-8.0.27-1.el7.x86_64.rpm
mysql-community-server-8.0.27-1.el7.x86_64.rpm
mysql-community-test-8.0.27-1.el7.x86_64.rpm
[root@localhost ~]#
删除残留的MariaDB
[root@localhost ~]# rpm -qa|grep mariadb
mariadb-libs-5.5.68-1.el7.x86_64
[root@localhost ~]# rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64
[root@localhost ~]#
二次检查:
[root@localhost ~]# rpm -qa|grep mariadb
[root@localhost ~]#
开始安装:
rpm -ivh --nodeps --force mysql-community-common-8.0.27-1.el7.x86_64.rpm
rpm -ivh --nodeps --force mysql-community-libs-8.0.27-1.el7.x86_64.rpm
rpm -ivh --nodeps --force mysql-community-libs-compat-8.0.27-1.el7.x86_64.rpm
rpm -ivh --nodeps --force mysql-community-client-8.0.27-1.el7.x86_64.rpm
rpm -ivh --nodeps --force mysql-community-client-plugins-8.0.27-1.el7.x86_64.rpm
rpm -ivh --nodeps --force mysql-community-embedded-compat-8.0.27-1.el7.x86_64.rpm
rpm -ivh --nodeps --force mysql-community-server-8.0.27-1.el7.x86_64.rpm
查看我们安装的内容:
[root@localhost ~]# rpm -qa | grep mysql
mysql-community-libs-8.0.27-1.el7.x86_64
mysql-community-server-8.0.27-1.el7.x86_64
mysql-community-client-plugins-8.0.27-1.el7.x86_64
mysql-community-libs-compat-8.0.27-1.el7.x86_64
mysql-community-embedded-compat-8.0.27-1.el7.x86_64
mysql-community-common-8.0.27-1.el7.x86_64
mysql-community-client-8.0.27-1.el7.x86_64
[root@localhost ~]#
查看当前MySQL服务状态:
[root@localhost ~]# systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: inactive (dead)
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
[root@localhost ~]#
不管MySQL是否运行还是不运行,都执行服务停止命令
[root@localhost ~]# service mysqld stop
Redirecting to /bin/systemctl stop mysqld.service
[root@localhost ~]#
执行初始化:
[root@localhost ~]# mysqld --initialize --console
[root@localhost ~]#
目录可写权限赋予:
[root@localhost ~]# chown -R mysql:mysql /var/lib/mysql/
[root@localhost ~]#
启动MySQL:
[root@localhost ~]# systemctl start mysqld
[root@localhost ~]#
查看服务状态:
[root@localhost ~]# systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since 日 2021-10-24 09:31:18 CST; 3s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 9201 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 9241 (mysqld)
Status: "Server is operational"
CGroup: /system.slice/mysqld.service
└─9241 /usr/sbin/mysqld 10月 24 09:31:04 localhost.localdomain systemd[1]: Starting MySQL Server...
10月 24 09:31:18 localhost.localdomain systemd[1]: Started MySQL Server.
[root@localhost ~]#
翻看日志文件,找到初始化的密码:
[root@localhost ~]# cat /var/log/mysqld.log
2021-10-24T01:29:47.674319Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.27) initializing of server in progress as process 8984
2021-10-24T01:29:47.888787Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-10-24T01:29:50.370284Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2021-10-24T01:29:54.018924Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1 is enabled for channel mysql_main
2021-10-24T01:29:54.022463Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1.1 is enabled for channel mysql_main
2021-10-24T01:29:54.293689Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: SoOu?/jep09>
2021-10-24T01:31:13.997176Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.27) starting as process 9241
2021-10-24T01:31:14.148958Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-10-24T01:31:15.775588Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2021-10-24T01:31:18.363257Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1 is enabled for channel mysql_main
2021-10-24T01:31:18.381048Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1.1 is enabled for channel mysql_main
2021-10-24T01:31:18.383717Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2021-10-24T01:31:18.383752Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2021-10-24T01:31:18.586545Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.27' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Community Server - GPL.
2021-10-24T01:31:18.586771Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock
[root@localhost ~]#
登陆MySQL,输入随机生成的密码:【SoOu?/jep09>】
[root@localhost ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.27 Copyright (c) 2000, 2021, Oracle and/or its affiliates. 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>
设置root用户密码永不过期:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;
更改root密码为123456:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
设置root账户允许被外部访问:
UPDATE mysql.`user` SET host = "%" WHERE user = "root";
刷新权限:
FLUSH PRIVILEGES;
退出:
QUIT;
防火墙拦截处理:
先查看防火墙状态:
[root@localhost ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: active (running) since 日 2021-10-24 09:55:25 CST; 5s ago
Docs: man:firewalld(1)
Main PID: 12734 (firewalld)
CGroup: /system.slice/firewalld.service
└─12734 /usr/bin/python2 -Es /usr/sbin/firewalld --nofork --nopid 10月 24 09:55:23 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...
10月 24 09:55:25 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.
10月 24 09:55:26 localhost.localdomain firewalld[12734]: WARNING: AllowZoneDrifting is enabled. This is considered an insecure configuration option. It will be removed in a future release. Please consider disabling it now.
[root@localhost ~]#
防火墙开启,没开放端口,会被拦截下来:

查看开放的端口列表:
[root@localhost ~]# firewall-cmd --zone=public --list-ports [root@localhost ~]#
开放3306端口:
[root@localhost ~]# firewall-cmd --zone=public --add-port=3306/tcp --permanent
success
[root@localhost ~]#
重新加载防火墙:
[root@localhost ~]# firewall-cmd --reload
success
[root@localhost ~]#
【Centos】RPM安装Mysql8的更多相关文章
- Linux(CentOS7)下rpm安装MySQL8.0.16
记录一下自己在 CentOS7 下 rpm 安装 MySQL8.0.16 的过程. 一.准备工作 1. 下载MySQL所需要的安装包 从 MySQL官网 下载,上传至 CentOS 系统 /usr/l ...
- CentOS下安装MYSQL8.X并设置忽略大小写
安装 在官网上下载:mysql80-community-release-el7-2.noarch.rpm.安装方式与5.7基本相同.详细安装过程见:CentOS下安装mysql5.7和mysql8.x ...
- Centos 7 安装Mysql8 主从同步复制
环境:Centos 7 软件:Mysql8 安装方式:Yum 1.从官网下载最新yum 源对应Cenots 7 版本安装: [root@DataNode-03 ~]# yum -y localinst ...
- 【Linux系列】Centos 7安装 Mysql8.0(五)
目的 本文主要介绍以下两点: 一. 如何安装Mysql8.0 二. Navicat连接Mysql 一. 如何安装Mysql8.0 安装Mysql有两种方式: 直接下载官方的源(比较慢) https:/ ...
- CentOS 7 安装MySQL8
安装 下载Linux对应的MySQL https://dev.mysql.com/downloads/mysql/ CentOS选择Red Hat Enterprise Linux 在/usr/loc ...
- CentOS RPM安装MySQL-5.6
1.检查是否有安装 安装之前应该先查询系统是否自在了mysql的软件包 rpm -qa|grep -i mysql 如果有的话需要先删除 rpm -e 软件名 --nodeps 2.下载安装包 cd/ ...
- CentOS RPM 安装 MySQL5.7
环境 CentOS 7 64位 MySQL 5.7 64位 1.卸载系统自带的 mariadb [root@localhost /]# rpm -qa|grep mariadb mariadb-lib ...
- CentOS 7 安装 MySql8.0
1-配置 Yum 库 rpm -Uvh https://repo.mysql.com/mysql80-community-release-el7-3.noarch.rpm 2-安装 MySql 2.1 ...
- CentOS如何安装MySQL8.0、创建用户并授权的详细步骤
# 安装相关软件 yum install -y gcc gcc-c++ openssl openssl-devel ncurses ncurses-devel make cmake # 获取MySQL ...
- centos rpm安装jdk1.8
1.官网下载jdk的rpm文件(http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) ...
随机推荐
- 透过 node-exporter 彻底弄懂机器监控:01. node-exporter 框架讲解
前言 Prometheus 生态里有很多采集器负责各类监控数据的采集,其中使用最广泛的,显然是 node-exporter,负责 Linux.BSD 等系统的常规监控指标的采集,比如 CPU.内存.硬 ...
- Vue学习:12.生命周期实例
两个小例子,巩固一下生命周期钩子函数. 实例1:初始化渲染 实现功能: 在 Vue 实例数据为空的情况下,用户在一进入页面就向服务器发送请求获取数据,并在数据返回后进行动态渲染. 思路: 创建一个 V ...
- 《Android开发卷——设置圆形头像,Android截取圆形图片》
在有一些程序开发中,有时候会用到圆形,截取一张图片的一部分圆形,作为头像或者其他. 本实例就是截图圆形,设置头像的. 首先讲解一些代码 <ImageView android:id=&q ...
- 雪花算法(SnowFlake)
引言 唯一ID可以标识数据的唯一性,在分布式系统中生成唯一ID的方案有很多,常见的方式大概有以下三种: 依赖数据库,使用如MySQL自增列或Oracle序列等. UUID随机数 snowflake雪花 ...
- Future集合会等线程池执行完才开始遍历吗?
先说结论:Future集合并不是等线程池执行完才开始遍历,而是线程池内的线程执行完一条Future集合就立即遍历一条 在使用线程池的业务场景下,我们经常需要获取线程执行的返回值,此时我们需要Calla ...
- 网络诊断工具iPerf的使用
iPerf 是一个网络性能测试工具,用于测量最大 TCP 和 UDP 带宽性能.它支持多种平台,包括 Windows.Linux.macOS 等.以下是 iPerf 的基本使用方法: 安装 iPerf ...
- Linux信号量
查看信号量 [root@localhost ~]# kill -l 1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP 6) SIGABRT 7) ...
- LangChain转换链:让数据处理更精准
上篇文章<5分钟了解LangChain的路由链>里主要介绍了路由链,核心类是LLMRouterChain和MultiPromptChain.本文介绍LangChain里的另外1个重要的链: ...
- 带有ttl的Lru在Rust中的实现及源码解析
TTL是Time To Live的缩写,通常意味着元素的生存时间是多长. 应用场景 数据库:在redis中我们最常见的就是缓存我们的数据元素,但是我们又不想其保留太长的时间,因为数据时间越长污染的可能 ...
- ThreadLocal 源码浅析
前言 多线程在访问同一个共享变量时很可能会出现并发问题,特别是在多线程对共享变量进入写入时,那么除了加锁还有其他方法避免并发问题吗?本文将详细讲解 ThreadLocal 的使用及其源码. 一.什么是 ...