Centos7 首次 安装Mysql8.0

随笔记录

背景介绍:重装Centos7 系统,没有安装mysql 

目录

1. 查看否有MariaDB与MySQL

2. MySQL官网下载适用于centos7的mysql安装包

2.1 查询服务器是x86_64架构还是arm架构

2.2 查系统版本

2.3 下载适用于系统版本安装包

2.3.1 国内镜像源下载安装包

2.3.2 安装 MySQL

2.3.3 运行 MySQL 

2.3.4 初始化

2.3.5 查看默认密码

2.3.6 登录

2.3.7 重置root密码

2.3.7.1 重置密码不符合mysql8.0 策略要求

2.3.7.2 重置密码符合Mysql8.0 策略要求

2.3.7.3 查看 mysql 初始的密码策略

2.3.7.4 首先需要设置密码的验证强度等级,设置 validate_password_policy 的全局参数为 LOW 

2.3.7.5 当前密码长度为 8 ,可以设置为4位的密码:

2.3.7.6 查看修改后的密码策略

2.3.7.7 修改简单密码

2.3.7.8 重启mysql 服务后,新密码登录

2.3.8  检查是否已经设置为开机启动MySQL服务

2.3.9 Mysql 设置远程

2.3.9.1  查看mysql 连接

2.3.9.2 查看可登录mysql的host

2.3.9.3  修改Mysql 远程连接 :修改root用户的host值,并刷新mysql数据库

 2.3.9.4 Navicate 远程连接Mysql8.0 成功

2.4 官网下载,太慢


1. 查看否有MariaDBMySQL


# ​查本地是否有相应的mysql(或者先检查是否有mariadb存在)
​[root@localhost Tools]# ps ajx|grep mariadb
210088 228505 228504 210088 pts/1    228504 S+       0   0:00 grep --color=auto mariadb
[root@localhost Tools]#
[root@localhost Tools]# ps ajx|grep mysql
210088 228537 228536 210088 pts/1    228536 S+       0   0:00 grep --color=auto mysql
[root@localhost Tools]#注意: MariaDB是一种开源的关系型数据库管理系统(RDBMS),它是MySQL的一个分支。
它提供了与MySQL高度兼容的功能和语法,同时还具有一些额外的功能和改进

2. MySQL官网下载适用于centos7的mysql安装包

2.1 查询服务器是x86_64架构还是arm架构
# uname -m 
or 
# arch  [root@localhost Tools]# uname -m
x86_64
[root@localhost Tools]#
[root@localhost Tools]# arch
x86_64                                       # linux 服务器 x86_64
[root@localhost Tools]#
2.2 查系统版本
[root@localhost Tools]# cat /etc/centos-release
CentOS Linux release 7.9.2009 (Core)
[root@localhost Tools]#
[root@localhost Tools]#
[root@localhost Tools]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
[root@localhost Tools]#
[root@localhost Tools]#
2.3 下载适用于系统版本安装包
2.3.1 国内镜像源下载安装包

官方的软件仓库下载速度可能较慢,建议采用国内的镜像。如果采用清华镜像,下面链接的方法:

mysql | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror

# /etc/yum.repos.d/ 路径下新建 mysql-community.repo
[root@localhost Tools]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
CentOS-Base.repo       CentOS-fasttrack.repo  CentOS-Vault.repo          epel.repo
CentOS-CR.repo         CentOS-Media.repo      CentOS-x86_64-kernel.repo  epel-testing.repo
CentOS-Debuginfo.repo  CentOS-Sources.repo    docker-ce.repo
[root@localhost yum.repos.d]#
[root@localhost yum.repos.d]# vi mysql-community.repo
[root@localhost yum.repos.d]#
[root@localhost yum.repos.d]#[root@localhost Tools]# cat  /etc/yum.repos.d/mysql-community.repo
[mysql-connectors-community]
name=MySQL Connectors Community
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-connectors-community-el7-$basearch/
enabled=1
gpgcheck=1
gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql-2022[mysql-tools-community]
name=MySQL Tools Community
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-tools-community-el7-$basearch/
enabled=1
gpgcheck=1
gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql-2022[mysql-8.0-community]
name=MySQL 8.0 Community Server
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-8.0-community-el7-$basearch/
enabled=1
gpgcheck=1
gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
[root@localhost Tools]#
2.3.2 安装 MySQL
#  yum install mysql-community-server
# 以上命令除了会安装 mysql-community-server (MySQL server),还会安装它依赖的其它软件包。[root@localhost Tools]# yum install mysql-community-server
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile* base: mirrors.bfsu.edu.cn* epel: mirrors.bfsu.edu.cn* extras: mirrors.bfsu.edu.cn* updates: mirrors.aliyun.com
mysql-8.0-community                                                 | 3.0 kB  00:00:00
mysql-connectors-community                                          | 3.0 kB  00:00:00
mysql-tools-community                                               | 3.0 kB  00:00:00
(1/3): mysql-tools-community/x86_64/primary_db                      |  98 kB  00:00:00
(2/3): mysql-8.0-community/x86_64/primary_db                        | 279 kB  00:00:00
(3/3): mysql-connectors-community/x86_64/primary_db                 | 109 kB  00:00:00
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:8.0.35-1.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 8.0.35-1.el7 for package: mysql-community-server-8.0.35-1.el7.x86_64
--> Processing Dependency: mysql-community-icu-data-files = 8.0.35-1.el7 for package: mysql-community-server-8.0.35-1.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 8.0.11 for package: mysql-community-server-8.0.35-1.el7.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:8.0.35-1.el7 will be installed
--> Processing Dependency: mysql-community-client-plugins = 8.0.35-1.el7 for package: mysql-community-client-8.0.35-1.el7.x86_64
--> Processing Dependency: mysql-community-libs(x86-64) >= 8.0.11 for package: mysql-community-client-8.0.35-1.el7.x86_64
---> Package mysql-community-common.x86_64 0:8.0.35-1.el7 will be installed
---> Package mysql-community-icu-data-files.x86_64 0:8.0.35-1.el7 will be installed
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.68-1.el7 will be obsoleted
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-9.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-9.el7.x86_64
---> Package mysql-community-client-plugins.x86_64 0:8.0.35-1.el7 will be installed
---> Package mysql-community-libs.x86_64 0:8.0.35-1.el7 will be obsoleting
--> Running transaction check
---> Package mysql-community-libs-compat.x86_64 0:8.0.35-1.el7 will be obsoleting
--> Finished Dependency ResolutionDependencies Resolved===========================================================================================Package                           Arch      Version          Repository              Size
===========================================================================================
Installing:mysql-community-libs              x86_64    8.0.35-1.el7     mysql-8.0-community    1.5 Mreplacing  mariadb-libs.x86_64 1:5.5.68-1.el7mysql-community-libs-compat       x86_64    8.0.35-1.el7     mysql-8.0-community    669 kreplacing  mariadb-libs.x86_64 1:5.5.68-1.el7mysql-community-server            x86_64    8.0.35-1.el7     mysql-8.0-community     64 M
Installing for dependencies:mysql-community-client            x86_64    8.0.35-1.el7     mysql-8.0-community     16 Mmysql-community-client-plugins    x86_64    8.0.35-1.el7     mysql-8.0-community    3.5 Mmysql-community-common            x86_64    8.0.35-1.el7     mysql-8.0-community    665 kmysql-community-icu-data-files    x86_64    8.0.35-1.el7     mysql-8.0-community    2.2 MTransaction Summary
===========================================================================================
Install  3 Packages (+4 Dependent packages)Total download size: 89 M
Is this ok [y/d/N]: y                    # y
Downloading packages:
warning: /var/cache/yum/x86_64/7/mysql-8.0-community/packages/mysql-community-client-plugins-8.0.35-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
Public key for mysql-community-client-plugins-8.0.35-1.el7.x86_64.rpm is not installed
(1/7): mysql-community-client-plugins-8.0.35-1.el7.x86_64.rpm       | 3.5 MB  00:00:09
(2/7): mysql-community-common-8.0.35-1.el7.x86_64.rpm               | 665 kB  00:00:00
(3/7): mysql-community-icu-data-files-8.0.35-1.el7.x86_64.rpm       | 2.2 MB  00:00:03
(4/7): mysql-community-libs-8.0.35-1.el7.x86_64.rpm                 | 1.5 MB  00:00:02
(5/7): mysql-community-libs-compat-8.0.35-1.el7.x86_64.rpm          | 669 kB  00:00:00
(6/7): mysql-community-client-8.0.35-1.el7.x86_64.rpm               |  16 MB  00:00:40
(7/7): mysql-community-server-8.0.35-1.el7.x86_64.rpm               |  64 MB  00:01:18
-------------------------------------------------------------------------------------------
Total                                                      944 kB/s |  89 MB  00:01:36
Retrieving key from https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
Importing GPG key 0x3A79BD29:Userid     : "MySQL Release Engineering <mysql-build@oss.oracle.com>"Fingerprint: 859b e8d7 c586 f538 430b 19c2 467b 942d 3a79 bd29From       : https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
Is this ok [y/N]: y                  # y
Running transaction check
Running transaction test
Transaction test succeeded
Running transactionInstalling : mysql-community-common-8.0.35-1.el7.x86_64                              1/8Installing : mysql-community-client-plugins-8.0.35-1.el7.x86_64                      2/8Installing : mysql-community-libs-8.0.35-1.el7.x86_64                                3/8Installing : mysql-community-client-8.0.35-1.el7.x86_64                              4/8Installing : mysql-community-icu-data-files-8.0.35-1.el7.x86_64                      5/8Installing : mysql-community-server-8.0.35-1.el7.x86_64                              6/8Installing : mysql-community-libs-compat-8.0.35-1.el7.x86_64                         7/8Erasing    : 1:mariadb-libs-5.5.68-1.el7.x86_64                                      8/8Verifying  : mysql-community-client-plugins-8.0.35-1.el7.x86_64                      1/8Verifying  : mysql-community-common-8.0.35-1.el7.x86_64                              2/8Verifying  : mysql-community-icu-data-files-8.0.35-1.el7.x86_64                      3/8Verifying  : mysql-community-libs-8.0.35-1.el7.x86_64                                4/8Verifying  : mysql-community-client-8.0.35-1.el7.x86_64                              5/8Verifying  : mysql-community-libs-compat-8.0.35-1.el7.x86_64                         6/8Verifying  : mysql-community-server-8.0.35-1.el7.x86_64                              7/8Verifying  : 1:mariadb-libs-5.5.68-1.el7.x86_64                                      8/8Installed:mysql-community-libs.x86_64 0:8.0.35-1.el7mysql-community-libs-compat.x86_64 0:8.0.35-1.el7mysql-community-server.x86_64 0:8.0.35-1.el7Dependency Installed:mysql-community-client.x86_64 0:8.0.35-1.el7mysql-community-client-plugins.x86_64 0:8.0.35-1.el7mysql-community-common.x86_64 0:8.0.35-1.el7mysql-community-icu-data-files.x86_64 0:8.0.35-1.el7Replaced:mariadb-libs.x86_64 1:5.5.68-1.el7Complete!
[root@localhost Tools]#
2.3.3 运行 MySQL 
[root@localhost Tools]#
[root@localhost Tools]# systemctl start mysqld
[root@localhost Tools]#
2.3.4 初始化
# 初始化
# mysqld --initialize[root@localhost Tools]# mysqld --initialize
[root@localhost Tools]#
[root@localhost Tools]# grep 'temporary password' /var/log/mysqld.log
2023-12-11T06:19:02.169003Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: np1bH=nX7STs
[root@localhost Tools]#
2.3.5 查看默认密码
# 查看默认密码
# localhost后面的最后的那一大串字符,就是密码,复制下来。[root@localhost Tools]#
[root@localhost Tools]# grep 'temporary password' /var/log/mysqld.log
2023-12-11T06:19:02.169003Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: np1bH=nX7STs              # 密码:np1bH=nX7STs 
[root@localhost Tools]#
2.3.6 登录

# 登录
# mysql -uroot -p[root@localhost Tools]# mysql -uroot -p
Enter password:             #输入 2.3.5 查询的默认密码后回车即可登录 mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.35Copyright (c) 2000, 2023, 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>
2.3.7 重置root密码
2.3.7.1 重置密码不符合mysql8.0 策略要求
#安装Mysql8.0后,第一次登录执行除修改密码的相关语句会出现如下错误(如图所示):mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'yusur666';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql>
2.3.7.2 重置密码符合Mysql8.0 策略要求
# mysql 8.0 密码策略要求 
# 密码必须为8位,需要一个以上的小写字母和大写字母,需要一个以上的数字以及需要一个以上的特殊字符
# 如果登录后不修改密码,基本无法做任何操作mysql> alter user 'root'@'localhost' identified by 'Yusur@666';
Query OK, 0 rows affected (0.02 sec)mysql>
2.3.7.3 查看 mysql 初始的密码策略
mysql> show variables like 'validate%';
+-------------------------------------------------+--------+
| Variable_name                                   | Value  |
+-------------------------------------------------+--------+
| validate_password.changed_characters_percentage | 0      |
| validate_password.check_user_name               | ON     |
| validate_password.dictionary_file               |        |
| validate_password.length                        | 8      |
| validate_password.mixed_case_count              | 1      |
| validate_password.number_count                  | 1      |
| validate_password.policy                        | MEDIUM |
| validate_password.special_char_count            | 1      |
+-------------------------------------------------+--------+
8 rows in set (0.00 sec)mysql>
2.3.7.4 首先需要设置密码的验证强度等级,设置 validate_password_policy 的全局参数为 LOW 
mysql> set global validate_password.policy=LOW;
Query OK, 0 rows affected (0.00 sec)mysql> 
2.3.7.5 当前密码长度为 8 ,可以设置为4位的密码:
mysql> set global validate_password.length=4;
Query OK, 0 rows affected (0.00 sec)mysql>
2.3.7.6 查看修改后的密码策略
mysql> show variables like 'validate%';
+-------------------------------------------------+-------+
| Variable_name                                   | Value |
+-------------------------------------------------+-------+
| validate_password.changed_characters_percentage | 0     |
| validate_password.check_user_name               | ON    |
| validate_password.dictionary_file               |       |
| validate_password.length                        | 4     |
| validate_password.mixed_case_count              | 1     |
| validate_password.number_count                  | 1     |
| validate_password.policy                        | LOW   |
| validate_password.special_char_count            | 1     |
+-------------------------------------------------+-------+
8 rows in set (0.01 sec)mysql>
2.3.7.7 修改简单密码
# alter user 'root'@'localhost' identified by '<simple new password>';mysql> alter user 'root'@'localhost' identified by 'yusur666';
Query OK, 0 rows affected (0.02 sec)mysql>
2.3.7.8 重启mysql 服务后,新密码登录
# 重启mysql f服务,后重新登录
[root@localhost Tools]# systemctl restart mysqld.service
[root@localhost Tools]#
[root@localhost Tools]# mysql -uroot -p
Enter password:                               #输入新密码
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.35 MySQL Community Server - GPLCopyright (c) 2000, 2023, 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>
2.3.8  检查是否已经设置为开机启动MySQL服务
[root@localhost Tools]#
[root@localhost Tools]# systemctl list-unit-files|grep mysqld
mysqld.service                                enabled    # 已设置为开机启动
mysqld@.service                               disabled
[root@localhost Tools]## 如果没有设置为开机启动则执行# systemctl enable mysqld.service
2.3.9 Mysql 设置远程

Naviicate 远程连接Mysql 时出错,可能因为Mysql 没有设置远程连接,仅支持本地连接

2.3.9.1  查看mysql 连接
mysql>
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.01 sec)mysql>
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 -ADatabase changed
mysql>
2.3.9.2 查看可登录mysql的host
# select host, user from user; mysql> select host,user from user;
+-----------+------------------+
| host      | user             |
+-----------+------------------+
| localhost | mysql.infoschema |             
| localhost | mysql.session    |
| localhost | mysql.sys        |
| localhost | root             |
+-----------+------------------+
4 rows in set (0.00 sec)mysql># host部分全部都是localhost,说明用户只能本地连接msyql服务
2.3.9.3  修改Mysql 远程连接 :修改root用户的host值,并刷新mysql数据库
# update user set user.host=’%'where user.user=‘root’;
# flush privileges;mysql> update user set user.host='%' where user.user='root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0mysql>
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)mysql>
mysql> select host,user from user;
+-----------+------------------+
| host      | user             |
+-----------+------------------+
| %         | root             |
| localhost | mysql.infoschema |
| localhost | mysql.session    |
| localhost | mysql.sys        |
+-----------+------------------+
4 rows in set (0.00 sec)mysql>
 2.3.9.4 Navicate 远程连接Mysql8.0 成功

2.4 官网下载,太慢

 注意:此处徐Oracel Accout,并登录

 到此 Centos7 第一次安装 Mysql8.0  已完成操作

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/269470.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

JVM面试

提示&#xff1a;文章写完后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 文章目录 1.JVM 的整体结构2.类加载做了哪些事情?类加载器有哪些&#xff1f;双亲委派和沙箱安全 3.Java虚拟机栈是什么4.方法区的理解HotSpot 中方法区的演进方法区的内部结…

12月12日作业

设计一个闹钟 头文件 #ifndef WIDGET_H #define WIDGET_H#include <QWidget> #include <QTimerEvent> #include <QTime> #include <QTime> #include <QTextToSpeech>QT_BEGIN_NAMESPACE namespace Ui { class Widget; } QT_END_NAMESPACEclass …

【Unity学习笔记】光照简介

本节主要是简单介绍一些常见的光照组件和渲染设置。 文章目录 灯光类型平行光Directional Light点光源Point Light聚光灯Spot Light面积光 Area Light 阴影设置全局光照明光照模式直接光照与间接光照Mixed Lighting 光照探针Light Probe Group光照探针组 反射探针 灯光类型 在…

GeMap:Online Vectorized HD Map Construction using Geometry

参考代码&#xff1a;GeMap 动机与出发点 出了原本针对单点的L1损失&#xff0c;车道线具备的几何结构信息作为监督信息也可以再被挖掘挖掘&#xff0c;像车道线实例中点和点之间的距离与夹角、线与线之间的夹角、不同线上点与点之间的关系都可用来作为监督约束&#xff0c;但…

手持式心电图机|12道便携式心电图机主板方案定制

心电图机被广泛应用于心脏状况的监测&#xff0c;可以从多个角度观察心脏情况&#xff0c;及时反映患者的病情&#xff0c;以便医生和患者了解。触摸屏使得控制和信息录入变得轻松。心电图报告提供多种语言选择&#xff0c;便于上传信息&#xff0c;实现无纸化报告。同时&#…

Jemeter,提取响应体中的数据:正则表达式、Json提取器

一、正则表达式 1、线程组--创建线程组&#xff1b; 2、线程组--添加--取样器--HTTP请求&#xff1b; 3、Http请求--添加--后置处理器--正则表达式提取器&#xff1b; 4、线程组--添加--监听器--查看结果树&#xff1b; 5、线程组--添加--取样器--调试取样器。 响应体数据…

各地加速“双碳”落地,数字能源供应商怎么选?

作者 | 曾响铃 文 | 响铃说 随着我国力争2030年前实现“碳达峰”、2060年前实现“碳中和”的“双碳”目标提出&#xff0c;为各地区、各行业的低碳转型和绿色可持续发展制定“倒计时”时间表&#xff0c;一场围绕“数字能源”、“智慧能源”、“新能源”等关键词的创新探索进…

matlab 最小二乘拟合空间直线(方法三)

目录 一、算法原理1、算法过程2、参考文献二、代码实现三、结果展示四、相关链接博客长期更新,GPT与爬虫自重,你也未必能爬到最新版本。 一、算法原理 1、算法过程 空间直线的点向式方程为:

数据采集网关:工业数据采集上云

数据采集网关&#xff0c;以其高效、便捷的特点&#xff0c;成为了现代工业物联网数据采集处理的重要工具。它是连接不同数据源和数据接收设备的桥梁&#xff0c;将各种形式和格式的数据快速、安全地汇聚到一起。通过数据采集网关&#xff0c;企业可以轻松实现数据的整合、转换…

掌握 Python sympy 库的高级计算技巧

更多资料获取 &#x1f4da; 个人网站&#xff1a;ipengtao.com Sympy是Python中一个强大的符号计算库&#xff0c;为数学和科学计算提供了丰富的功能。本文将深入介绍Sympy库的各项功能&#xff0c;并提供丰富的示例代码&#xff0c;以帮助大家更好地理解和应用这一工具。 S…

Linux--操作系统

1. 常见的操作系统 Windowsmac OSLinuxiOSAndroid 2. 操作系统的定义 操作系统直接运行在计算机上的系统软件&#xff0c; 它是控制硬件和支持软件运行的计算机程序。 3. 操作系统的作用 向下控制硬件向上支持软件的运行&#xff0c;具有承上启下的作用。 4.总结 操作系统…

Android View闪烁动画AlphaAnimation,Kotlin

Android View闪烁动画AlphaAnimation&#xff0c;Kotlin private fun flickerAnimation(view: View?) {val animation: Animation AlphaAnimation(1f, 0f) //不透明到透明。animation.duration 500 // 1次过程时长。animation.interpolator LinearInterpolator() // 线性速…