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环境下安装jdk和Tomcat详细步骤

    下面是Linux环境下安装JDK和Tomcat的详细步骤: 安装JDK 首先从Oracle的官方网站(https://www.oracle.com/java/technologies/javase-downloads.html)下载JDK的安装包,选择适合你系统的版本。 在Linux的终端(命令行)中解压安装包。可以使用以下命令: tar -zxvf jdk…

    Linux 2023年5月14日
    00
  • CentOS7使用dnf安装mysql的方法

    下面就为您详细讲解一下“CentOS7使用dnf安装mysql的方法”的完整攻略。 步骤一:安装dnf 首先,您需要先在您的CentOS 7系统中安装dnf。进行如下操作即可安装: sudo yum install epel-release -y sudo yum install dnf -y 步骤二:添加MySQL 8.0的repository 接下来,您…

    Linux 2023年5月14日
    00
  • Linux lsblk命令

    Linux lsblk命令的作用 Linux lsblk命令用于列出系统中所有的块设备,包括硬盘、U盘、光驱等等。它可以显示设备的名称、大小、挂载点等信息,方便用户查看和管理系统中的块设备。 Linux lsblk命令的使用方法 Linux lsblk命令的基本语法如下: lsblk [选项] [设备] 其中,选项和设备都是可选的。如果不指定设备,则默认列出…

    Linux 2023年5月10日
    00
  • Linux操作系统原理笔记

        在Linux操作系统内核内部,进程是通过一个链表,而且是一个双向链表来管理的。 进程描述符:每一个进程都有其描述符,每一个描述符彼此之间都有关联性的。   双向链表:   一个进程内部可能包含多个线程。     上下文切换(Context swtch)     假如说进程A从当前CPU上被拿走,切换成进程B,进程A有自己的描述符(task_struc…

    Linux 2023年4月11日
    00
  • UDP内核发包流程

    背景 工作中遇到客户反馈,上层应用UDP固定间隔100ms发包,但本地tcpdump抓包存在波动,有的数据包之间间隔107ms甚至更多,以此重新梳理了下udp的发送流程。 udp发包流程 udp_sendmsg UDP corking 是一项优化技术,允许内核将多次数据累积成单个数据报发送。在用户程序中有两种方法可以启用此选项: 使用 setsockopt …

    Linux 2023年5月8日
    00
  • Linux各项目环境部署记录(换服务器部署脚本整理)

    对于“Linux各项目环境部署记录(换服务器部署脚本整理)”这个主题,我可以给出如下的详细攻略。 1. 确定部署目标 在进行环境部署之前,我们需要先明确自己的部署目标,例如是要搭建一个Web服务器、还是要部署一个数据库服务器等等。不同的目标对应着不同的环境配置,因此要根据需要选择合适的环境配置方案。 2. 确定操作系统版本 在确定了部署目标之后,我们需要选择…

    Linux 2023年5月14日
    00
  • 自动生成linux网卡配置脚本分享

    非常感谢您对我们网站“自动生成linux网卡配置脚本分享”的关注。以下是该攻略的详细讲解: 什么是自动生成linux网卡配置脚本? 自动生成linux网卡配置脚本是一种简便的方式来自动化生成Linux网卡配置文件。这种方法可以防止出现常见的网络配置问题,如拼写错误、参数错误等。该脚本使用Bash编写,它将获取网卡的信息,并将这些信息放入配置文件中。 如何自动…

    Linux 2023年5月24日
    00
  • Linux服务器下Nginx与Apache共存的实现方法分析

    以下是“Linux服务器下Nginx与Apache共存的实现方法分析”的完整使用攻略,包含两个示例说明。 安装Nginx和Apache 打开终端。在Linux系统中,您可以通过下“Ctrl + T”组合键来打开终端。 更新软件包列表。在终端中输入以下命令: sudo apt-get update 安装Ngin服务器。在终端中输入以下命令: sudo apt-…

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