Centos7 安装mysql 8.0.13(rpm)的教程详解

Centos7安装MySQL8.0.13(RPM)的教程详解

1. 先决条件

在开始安装MySQL前,确保系统上已经安装并启用了epel和remi软件仓库

sudo yum install epel-release
sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

安装完成后,启用remi存储库并设置默认活动存储库为remi-php71(当前版本的PHP是7.1.x)

sudo yum-config-manager --enable remi
sudo yum-config-manager --setopt=remi-php71.enabled=1
sudo yum-config-manager --save --setopt=remi-php71.enabled=1

2. 下载MySQL8.0.13 RPM软件包

MySQL官方网站上可以下载到RPM包, 下载地址:https://dev.mysql.com/downloads/mysql/
选择“MySQL Community Server”,然后选择“MySQL Community Server 8.0.13”,最后选择CentOS Linux中的版本。

3. 安装MySQL8.0.13 RPM包

在下载RPM软件包之后,使用以下命令进行安装

sudo rpm -ivh mysql-community-server-version_number.rpm

在我的机器上,我下载了名为mysql-community-server-8.0.13-1.el7.x86_64.rpm的MySQL最新版本。如果到MySQL的官方网站上下载的话,根据不同的CentOS版本选择不同的文件名称。

4. 开始MySQL服务

安装MySQL8 RPM包后,可以使用以下命令启动MySQL服务。

sudo systemctl start mysqld.service

5. 配置MySQL

在第一次启动MySQL服务之前,需要进行一些配置才能顺利启动。

sudo mysql_secure_installation

6. 登录MySQL

完成MySQL安装后,可以使用以下命令登录MySQL。

mysql -u root -p

下面是一个示例

[root@localhost ~]# sudo yum install epel-release
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * epel: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:7-11 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================================
 Package                                  Arch                                Version                               Repository                         Size
=============================================================================================================================================================
Installing:
 epel-release                             noarch                              7-11                                  extras                             15 k

Transaction Summary
=============================================================================================================================================================
Install  1 Package

Total download size: 15 k
Installed size: 24 k
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/extras/packages/epel-release-7-11.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Public key for epel-release-7-11.noarch.rpm is not installed
epel-release-7-11.noarch.rpm                                                                                                              |  15 kB  00:00:00     
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0x6A2FAEA2352C64E5:
 Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
 Fingerprint: 6341 ab27 53d7 8a78 a7c2  7bb1 24c6 a8a7 f4a8 0eb5
 Package    : centos-release-7-6.1810.2.el7.centos.x86_64 (@anaconda)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : epel-release-7-11.noarch                                                                                                                      1/1 
  Verifying  : epel-release-7-11.noarch                                                                                                                      1/1 

Installed:
  epel-release.noarch 0:7-11                                                                                                                                  

Complete!
[root@localhost ~]# sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
Loaded plugins: fastestmirror
remi-release-7.rpm                                                                                                                   |  23 kB  00:00:00     
Examining /var/tmp/yum-root-QJ2RQO/remi-release-7.rpm: remi-release-7.6-1.el7.remi.noarch
Marking /var/tmp/yum-root-QJ2RQO/remi-release-7.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package remi-release.noarch 0:7.6-1.el7.remi will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================================
 Package                                 Arch                                Version                                      Repository                       Size
=============================================================================================================================================================
Installing:
 remi-release                            noarch                              7.6-1.el7.remi                               /remi-release-7.rpm             17 k

Transaction Summary
=============================================================================================================================================================
Install  1 Package

Total size: 17 k
Installed size: 17 k
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : remi-release-7.6-1.el7.remi.noarch                                                                                                         1/1 
  Verifying  : remi-release-7.6-1.el7.remi.noarch                                                                                                         1/1 

Installed:
  remi-release.noarch 0:7.6-1.el7.remi                                                                                                                       

Complete!
[root@localhost ~]# sudo yum-config-manager --enable remi
Loaded plugins: fastestmirror
========================= repo: remi =========================
[remi]
bandwidth = 0
base_persistdir = /var/lib/yum/repos/x86_64/7
baseurl = 
cache = 0
cachedir = /var/cache/yum/x86_64/7/remi
cost = 1000
enabled = 1
enablegroups = True
exclude = 
failovermethod = priority
fastestmirror_enabled = 0
gpgcadir = /var/lib/yum/repos/x86_64/7/remi/gpgcadir
gpgcakey = 567E347AD24C6FF5A0AAE9E04C889DF527C6ADB1 6D269B33D25F820DDE99314A4F9FFF828C66F0CD
gpgcheck = 1
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
http_caching = all
includepkgs = 
ip_resolve = 
keepalive = True
keepcache = 0
mddownloadpolicy = sqlite
mdpolicy = group:small
mediaid = 
metadata_expire = 21600
metadata_expire_filter = read-only:present
metalink = 
minrate = 0
mirrorlist = 
mirrorlist_expire = 86400
name = Remi's RPM repository for Enterprise Linux 7 - remi
old_base_cache_dir = 
password = 
persistdir = /var/lib/yum/repos/x86_64/7/remi
pkgdir = /var/cache/yum/x86_64/7/remi/packages
proxy = False
proxy_dict = 
proxy_password = 
proxy_username = 
repo_gpgcheck = 1
report_instanceid = True
retries = 10
skip_if_unavailable = False
ssl_check_cert_permissions = True
sslcacert = 
sslclientcert = 
sslclientkey = 
sslverify = True
throttle = 0
timeout = 30.0
ui_id = remi/x86_64
ui_repoid_vars = releasever,
   basearch
username = 
[root@localhost ~]# sudo yum-config-manager --setopt=remi-php71.enabled=1
[root@localhost ~]# sudo yum-config-manager --save --setopt=remi-php71.enabled=1
[root@localhost ~]# wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-community-server-8.0.13-1.el7.x86_64.rpm
--2019-11-14 23:44:51--  https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-community-server-8.0.13-1.el7.x86_64.rpm
Resolving dev.mysql.com (dev.mysql.com)... 137.254.60.11
Connecting to dev.mysql.com (dev.mysql.com)|137.254.60.11|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 63148880 (60M) [application/octet-stream]
Saving to: ‘mysql-community-server-8.0.13-1.el7.x86_64.rpm’

mysql-community-server-8.0.13-1.el7.x86_64.rpm                     100%[==============================================================================>]  60.24M  8.27MB/s    in 16s     

2019-11-14 23:45:08 (3.79 MB/s) - ‘mysql-community-server-8.0.13-1.el7.x86_64.rpm’ saved [63148880/63148880]

[root@localhost ~]# sudo rpm -ivh mysql-community-server-8.0.13-1.el7.x86_64.rpm 
warning: mysql-community-server-8.0.13-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 8c718d3b: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-client-8.0.13-1.el######################################### [ 17%]
   2:mysql-community-server-8.0.13-1.el######################################### [ 33%]
MySQL Community Server                                                   ################################# [100%]
[root@localhost ~]# sudo systemctl start mysqld.service
[root@localhost ~]# sudo 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 2019-11-06 10:50:51 CST; 1 weeks 1 days ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 18609 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 18626 (mysqld)
   Status: "Server is operational"
   CGroup: /system.slice/mysqld.service
           └─18626 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
[root@localhost ~]# sudo mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root:  ******   #第一次输入root密码
The existing password for the user account root has expired. Please set a new password.

New password:   *****    #设置新密码
Re-enter new password:   *****    #再次输入新密码

VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No: n   #设置密码强度校验

Please set the password for root here.

New password:   *****    #检测一下新密码

Re-enter new password: *****   #再次输入一遍

By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y   #去掉匿名用户

Success.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n   #允许root远程登录

 ... skipping.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y    #删除test数据库

 - Dropping test database...
Success.

 - Removing privileges on test database...
Success.


Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y   #执行修改后生效

Success.

All done! 

本站文章如无特殊说明,均为本站原创,如若转载,请注明出处:Centos7 安装mysql 8.0.13(rpm)的教程详解 - Python技术站

(0)
上一篇 2023年5月14日
下一篇 2023年5月14日

相关文章

  • Linux centos7环境下tomcat安装教程

    Linux CentOS 7环境下Tomcat安装教程 简介 Apache Tomcat 是一个开放源代码的Web 应用程序服务器,是一个安全、灵活、可靠,以及易于使用的Java 应用程序服务器。本教程将讲解如何在Linux CentOS 7 系统下安装配置Tomcat 服务器。 安装前的准备 在开始安装 Tomcat 之前,需要确保已经安装Java JDK…

    Linux 2023年5月14日
    00
  • linux后台运行的几种方式(小结)

    我来为你详细讲解“linux后台运行的几种方式(小结)” 的攻略。 1. 前置知识 在讲解“linux后台运行的几种方式”之前,需要先了解以下概念: 什么是shell shell是一种基于字符的用户界面,它是用户与操作系统内核之间交互的接口。在UNIX和类UNIX系统中,Shell的种类很多,如sh(Bourne shell), bash(Bourne-Ag…

    Linux 2023年5月14日
    00
  • linux网站服务Apache的安装与配置方法详解

    以下是“Linux网站服务Apache的安装与配置方法详解”的完整使用攻略,包含两个示例说明。 安装Apache 打开终端并以下命令以更新软件包: bash apt update 安装Apache: bash sudo apt install apache2 启动Apache服务: bash sudo systemctl start apache2 验证Ap…

    Linux 2023年5月12日
    00
  • (新手向)在Linux中使用VScode编写 “Hello,world”程序,并编写测试-Ubuntu20.4

    本文意在帮助 Go 语言初学者在 Linux环境下编写自己的第一个Golang程序 难点主要在 VScode 中 Go 插件的下载 与 go.mod 以及编译运行和 第一个Go测试程序的使用   前提准备:安装Ubuntu20.4、安装Go并配置环境   1.下载并安装 VScode 编译器 (自行下载,不再赘述)   2.打开 VScode,按步骤安装中文…

    2023年4月8日
    00
  • Ubuntu 16.04 64位中搭建Node.js开发环境教程

    下面我将详细讲解“Ubuntu 16.04 64位中搭建Node.js开发环境教程”的完整攻略。 1. 安装Node.js 1.1 添加Node.js官方源 要安装Node.js,我们首先需要添加一个可以让我们安装最新版本Node.js的源。 在终端中执行以下命令: curl -sL https://deb.nodesource.com/setup_14.x…

    Linux 2023年5月24日
    00
  • Linux企业运维人员常用的150个命令分享

    Linux企业运维人员常用的150个命令分享 介绍 Linux是当前企业中最为流行的操作系统之一,由于其高度的安全性能,强大的稳定性以及丰富的工具支持,使得Linux成为企业中首选的操作系统之一。Linux企业运维人员需要掌握大量的命令行工具,以便更快速、更有效的管理Linux系统。本文将分享150个Linux企业运维人员必备的命令。 常用命令 以下是 Li…

    Linux 2023年5月14日
    00
  • linux防火墙配置教程之访问外网web实验(3)

    针对“linux防火墙配置教程之访问外网web实验(3)”这个话题,下面是完整攻略的详细讲解。 什么是Linux防火墙? Linux防火墙是一种可以保护Linux系统网络安全的工具,用于过滤和控制进出系统网络的数据流,保护网络资源和数据免受恶意攻击。Linux系统自带了一些常用的防火墙软件,如iptables、ufw等,本文中我们主要使用iptables。 …

    Linux 2023年5月14日
    00
  • [Linux] PHP程序员玩转Linux系列-自动备份与SVN

    1.PHP程序员玩转Linux系列-怎么安装使用CentOS 2.PHP程序员玩转Linux系列-lnmp环境的搭建 3.PHP程序员玩转Linux系列-搭建FTP代码开发环境 4.PHP程序员玩转Linux系列-备份还原MySQL 我的代码经常在开发修改,为了代码的安全性,比如哪天误删了文件,或者哪天改错东西了,可以恢复回来,我要搞代码备份.备份代码,我先…

    Linux 2023年4月13日
    00
合作推广
合作推广
分享本页
返回顶部