CentOS7.8安装mysql 8.0.20的教程详解
作者:Tomchao 发布时间:2024-01-21 00:07:39
一、安装mysql软件
下载并安装MySQL官方的 Yum Repository,Mysql版本8.0.20
wget -i -c
http://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
下载后直接yum安装
yum -y install mysql80-community-release-el7-3.noarch.rpm
安装MySQL服务器
yum -y install mysql-community-server
[root@CentOS Linux]# yum -y install mysql-community-server
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirror.lzu.edu.cn
* extras: mirror.lzu.edu.cn
* updates: mirror.lzu.edu.cn
mysql-connectors-community | 2.5 kB 00:00:00
mysql-tools-community | 2.5 kB 00:00:00
mysql80-community | 2.5 kB 00:00:00
(1/3): mysql-connectors-community/x86_64/primary_db | 57 kB 00:00:00
mysql-tools-community/x86_64/p FAILED B 00:51:07 ETA
http://repo.mysql.com/yum/mysql-tools-community/el/7/x86_64/repodata/12bd1e8730cd532791529877bf5e7babbbb02879-primary.sqlite.bz2: [Errno 12] Timeout on http://repo.mysql.com/yum/mysql-tools-community/el/7/x86_64/repodata/12bd1e8730cd532791529877bf5e7babbbb02879-primary.sqlite.bz2: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
Trying other mirror.
(2/3): mysql-tools-community/x86_64/primary_db | 72 kB 00:00:00
mysql80-community/x86_64/prima FAILED B 00:00:15 ETA
http://repo.mysql.com/yum/mysql-8.0-community/el/7/x86_64/repodata/833c637b3989c2dd5a079a045177d2f1c96e9c1e-primary.sqlite.bz2: [Errno 12] Timeout on http://repo.mysql.com/yum/mysql-8.0-community/el/7/x86_64/repodata/833c637b3989c2dd5a079a045177d2f1c96e9c1e-primary.sqlite.bz2: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
Trying other mirror.
(3/3): mysql80-community/x86_64/primary_db | 107 kB 00:00:00
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:8.0.20-1.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 8.0.20-1.el7 for package: mysql-community-server-8.0.20-1.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 8.0.11 for package: mysql-community-server-8.0.20-1.el7.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:8.0.20-1.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 8.0.11 for package: mysql-community-client-8.0.20-1.el7.x86_64
---> Package mysql-community-common.x86_64 0:8.0.20-1.el7 will be installed
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.65-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-libs.x86_64 0:8.0.20-1.el7 will be obsoleting
--> Running transaction check
---> Package mysql-community-libs-compat.x86_64 0:8.0.20-1.el7 will be obsoleting
--> Finished Dependency Resolution
Dependencies Resolved
===============================================================================================
Package Arch Version Repository Size
===============================================================================================
Installing:
mysql-community-libs x86_64 8.0.20-1.el7 mysql80-community 4.5 M
replacing mariadb-libs.x86_64 1:5.5.65-1.el7
mysql-community-libs-compat x86_64 8.0.20-1.el7 mysql80-community 1.2 M
replacing mariadb-libs.x86_64 1:5.5.65-1.el7
mysql-community-server x86_64 8.0.20-1.el7 mysql80-community 488 M
Installing for dependencies:
mysql-community-client x86_64 8.0.20-1.el7 mysql80-community 47 M
mysql-community-common x86_64 8.0.20-1.el7 mysql80-community 609 k
Transaction Summary
===============================================================================================
Install 3 Packages (+2 Dependent packages)
Total download size: 541 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/mysql80-community/packages/mysql-community-common-8.0.20-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Public key for mysql-community-common-8.0.20-1.el7.x86_64.rpm is not installed
(1/5): mysql-community-common-8.0.20-1.el7.x86_64.rpm | 609 kB 00:00:00
(2/5): mysql-community-libs-8.0.20-1.el7.x86_64.rpm | 4.5 MB 00:00:13
(3/5): mysql-community-libs-compat-8.0.20-1.el7.x86_64.rpm | 1.2 MB 00:00:04
mysql-community-client-8.0.20- FAILED B 00:22:23 ETA
http://repo.mysql.com/yum/mysql-8.0-community/el/7/x86_64/mysql-community-client-8.0.20-1.el7.x86_64.rpm: [Errno 12] Timeout on http://repo.mysql.com/yum/mysql-8.0-community/el/7/x86_64/mysql-community-client-8.0.20-1.el7.x86_64.rpm: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
Trying other mirror.
(4/5): mysql-community-server-8.0.20-1.el7.x86_64.rpm | 488 MB 00:22:18
(5/5): mysql-community-client-8.0.20-1.el7.x86_64.rpm | 47 MB 00:01:57
-----------------------------------------------------------------------------------------------
Total 376 kB/s | 541 MB 00:24:34
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:
Userid : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
Package : mysql80-community-release-el7-3.noarch (installed)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
Installing : mysql-community-common-8.0.20-1.el7.x86_64 1/6
Installing : mysql-community-libs-8.0.20-1.el7.x86_64 2/6
Installing : mysql-community-client-8.0.20-1.el7.x86_64 3/6
Installing : mysql-community-server-8.0.20-1.el7.x86_64 4/6
Installing : mysql-community-libs-compat-8.0.20-1.el7.x86_64 5/6
Erasing : 1:mariadb-libs-5.5.65-1.el7.x86_64 6/6
Verifying : mysql-community-libs-compat-8.0.20-1.el7.x86_64 1/6
Verifying : mysql-community-common-8.0.20-1.el7.x86_64 2/6
Verifying : mysql-community-server-8.0.20-1.el7.x86_64 3/6
Verifying : mysql-community-client-8.0.20-1.el7.x86_64 4/6
Verifying : mysql-community-libs-8.0.20-1.el7.x86_64 5/6
Verifying : 1:mariadb-libs-5.5.65-1.el7.x86_64 6/6
Installed:
mysql-community-libs.x86_64 0:8.0.20-1.el7
mysql-community-libs-compat.x86_64 0:8.0.20-1.el7
mysql-community-server.x86_64 0:8.0.20-1.el7
Dependency Installed:
mysql-community-client.x86_64 0:8.0.20-1.el7 mysql-community-common.x86_64 0:8.0.20-1.el7
Replaced:
mariadb-libs.x86_64 1:5.5.65-1.el7
Complete!
安装完成后就会覆盖掉之前的mariadb
二、配置Mysql数据库
启动MySQL
systemctl start mysqld.service
查看MySQL运行状态
systemctl status mysqld.service
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2020-05-13 23:57:41 HKT; 18s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 9563 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 9649 (mysqld)
Status: "Server is operational"
Tasks: 39
CGroup: /system.slice/mysqld.service
└─9649 /usr/sbin/mysqld
May 13 23:57:34 CentOS.highning.com systemd[1]: Starting MySQL Server...
May 13 23:57:41 CentOS.highning.com systemd[1]: Started MySQL Server.
找出root初始密码
grep "password" /var/log/mysqld.log
2020-05-13T15:57:37.815353Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 9*CxxNRWHqmL
进入数据库:
mysql -uroot -p
输入密码(密码是上面查询到的 ,/wsw6gif;eH ),此时不能操作数据库,必须修改密码之后才能操作数据库
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';
其中‘new password'替换成你要设置的密码,注意:密码设置必须要大小写字母数字和特殊符号(,/';:等),不然不能配置成功
三、开启mysql的远程访问
执行以下命令开启远程访问限制(注意:下面命令开启的IP是 192.168.0.1,如要开启所有的,用%代替IP),mysql8.0和以前的版本不一样,不能用原来的命令同时授权和创建用户:
create user 'root'@'192.168.0.1' identified by 'password';
grant all privileges on *.* to 'root'@'192.168.0.1' with grant option;
再输入以下两行命令
flush privileges;
exit
四、为firewalld添加开放端口
添加mysql端口3306和Tomcat端口8080
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --zone=public --add-port=8080/tcp --permanent
重新载入
firewall-cmd --reload
最后在windows下用mysql命令登录
Microsoft Windows [版本 10.0.18363.778]
(c) 2019 Microsoft Corporation。保留所有权利。
C:\Users\highning>mysql -h 192.168.88.88 -P 3306 -u root -p
Enter password: ********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.20 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> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
mysql>
修改密码安全策略,改为LOW,密码长度最小6位
mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+--------+
| Variable_name | Value |
+--------------------------------------+--------+
| 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 |
+--------------------------------------+--------+
7 rows in set (0.00 sec)
mysql> set global validate_password.policy=LOW;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password.length=6;
Query OK, 0 rows affected (0.00 sec)
mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+-------+
| Variable_name | Value |
+--------------------------------------+-------+
| validate_password.check_user_name | ON |
| validate_password.dictionary_file | |
| validate_password.length | 6 |
| validate_password.mixed_case_count | 1 |
| validate_password.number_count | 1 |
| validate_password.policy | LOW |
| validate_password.special_char_count | 1 |
+--------------------------------------+-------+
7 rows in set (0.00 sec)
关于 mysql 密码策略相关参数;
1)、validate_password.length 固定密码的总长度;
2)、validate_password_dictionary_file 指定密码验证的文件路径;
3)、validate_password_mixed_case_count 整个密码中至少要包含大/小写字母的总个数;
4)、validate_password_number_count 整个密码中至少要包含阿拉伯数字的个数;
5)、validate_password.policy 指定密码的强度验证等级,默认为 MEDIUM;
6)、validate_password_special_char_count 整个密码中至少要包含特殊字符的个数;
关于 validate_password.policy 的取值:
LOW:只验证长度;
MEDIUM:验证长度、数字、大小写、特殊字符;
STRONG:验证长度、数字、大小写、特殊字符、字典文件;
来源:https://segmentfault.com/a/1190000022637296


猜你喜欢
- 我就废话不多说了,直接上代码吧!import torchimport torch.nn as nnfrom torch.autograd i
- 方法一,利用 sheet.iter_rows() 获取 Sheet1 表中的所有行,然后遍历import openpyxl wb = ope
- 这篇文章主要介绍了JavaScript监听触摸事件代码实例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要
- 样式表是一种为超文本标签语言提供增强补充服务的技术,可对每一个html的标签做精雕细刻的修饰。只用html制作的网页,对页面内各部分的修饰能
- 禁用默认事务为了确保数据一致性,GORM 会在事务里执行写入操作(创建、更新、删除)。如果没有这方面的要求,您可以在初始化时禁用它,这将获得
- 目前定时的操作有:一、Html页面的定时刷新(Refresh--刷新 ) 1,Refresh (刷新) 代码使用说明 说明:让网页多长时间(
- numpy中的乘法A = np.array([[1, 2, 3], [2, 3, 4]])B = np.array([[1, 0, 1],
- 前言很多时候开发者需要删除文件。可能是他错误地创建了文件,或者不再需要该文件。无论出于何种原因,都有一些方法可以通过Python来删除文件,
- 本文实例讲述了PHP面向对象的特性。分享给大家供大家参考,具体如下:Demo1.php<?php header('
- 鼠标双击滚动屏幕,单击停止滚动,很多小说新闻网站都有这个很人性化的功能,阅读起小说、新闻来很方便,不用手动拉滚动条。js代码如下:<h
- 搞社区APP的时候,需要实现这个功能: String filetext = "//@张小名: 25分//@李小花: 43分//@王
- 使用Tensorflow进行深度学习训练的时候,需要对训练好的网络模型和各种参数进行保存,以便在此基础上继续训练或者使用。介绍这方面的博客有
- 代码很简单,只需要2行代码就可实现想要的功能,虽然很短,但确实使用,主要使用了requests库。测试2XX, 3XX, 4XX, 5XX都
- QQ和微信这两款都是非常受人喜欢的聊天交友软件!可能大家平时没有留意到,也或者是大家可能很少用微信,或者很少用QQ吧!所以可能没有留意这些小
- 本文实例为大家分享了python点球小游戏的具体代码,供大家参考,具体内容如下1.游戏要求: 设置球的方向:左中右三个方向,射门或者扑救动作
- 如何通过PHP实现Des加密算法代码实例注:php7以上不支持了,因为php7去掉了某些函数, 另外变量的{}要改为[]<?phpcl
- 1. 生成for 2005版本的数据库脚本 2008 的manger studio -- 打开"对象资源管理
- 一、绘制总体图形import numpy as npimport matplotlib.pyplot as pltfrom mpl_tool
- 不管是录入信息时需要用扫码器扫码录入、核对信息时用于扫码识别,还是有别的生成条形码的需要,那我们如何把表格中的数字、文本列快速生成条形码图片
- 当今互联网时代,数据处理已经成为了一个非常重要的任务。而Redis作为一款高性能的NoSQL数据库,越来越受到了广大开发者的喜爱。本篇博客将