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开发记录:在linux环境下编写代码(1)

      terminal,vi 的使用:          0.进入与使用   用终端进入,相当于windows的cmd.   ctrl+alt+T打开终端。   终端命令:ls查看文件夹下的文件   mkdir filename在当前目录下创造一个文件夹   cd filename 进入某文件夹   . 代表当前目录 .. 上层目录   ping  ipadr…

    Linux 2023年4月17日
    00
  • java开发的linux监控系统

    WGCLOUD基于java语言开发,是高性能高并发的分布式监控平台,核心模块包括:服务器集群监控,ES集群监控,CPU监控,内存监控,数据监控(mysql,oracle,pg等),服务心跳检测,应用进程管理,磁盘IO监控,系统负载监控,监控告警信息推送。  WGCLOUD非常轻量级,可以说在基础监控领域做的最优秀。 和Zabbix类似,WGCLOUD也是一个…

    Linux 2023年4月13日
    00
  • linux服务器系统CentOS、uBuntu、Gentoo、FreeBSD、Debian的比较

    比较五种linux服务器系统 CentOS CentOS(Community Enterprise Operating System),是由Red Hat公司出品的RHEL(Red Hat Enterprise Linux)源代码所编译而成,是一种自由社区企业操作系统。CentOS有很多特征,例如: 稳定性、可靠性、安全性以及广泛的软件支持。 uBuntu …

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

    lpstat是Linux下的一条打印机状态指令,它可以用来查询打印机状态,控制打印任务,管理打印机等。 作用 lpstat命令可以: 查询打印机状态,输出打印队列信息 列出系统中已知的打印机列表以及它们的状态 在命令行显示打印机服务状态 使用方法 lpstat [options] [printer_or_class …] 常用选项: -a:显示所有打印机…

    Linux 2023年3月28日
    00
  • 手把手教你把nodejs部署到linux上跑出hello world

    让我为你详细讲解怎样通过手把手教程,把Node.js部署到Linux上跑出Hello World的完整攻略。 准备工作 在开始部署之前,需要确保你的Linux系统已经安装好Node.js运行环境。如果没有安装,可以参考官方文档在线安装或下载安装包手动安装。 步骤一:创建工作目录 首先,我们需要在Linux系统上创建一个工作目录,用来存放相关文件及源代码。在终…

    Linux 2023年5月24日
    00
  • linux下操作oracle

    ps -ef|grep ora #查看oracle状态 lsnrctl status #查看监听的状态 lsnrctl start |stop |reload #启动|停止|重启 监听 登录oracle su – oracle sqlplus / as sysdba SQL>startup #启动oracle SQL>shutdown #关闭or…

    Linux 2023年4月13日
    00
  • win10下如何运行.sh文件的实现步骤

    运行 “.sh” 文件是在Linux和MacOS系统中常见的一种操作,但在Windows系统中,通常需要进行额外的配置才能运行 “.sh” 文件。下面介绍在Windows 10系统中如何运行 “.sh” 文件的实现步骤: 1. 安装Git Bash Git Bash是Git工具自带的一个Bash shell,在Windows系统中提供了一种Linux-lik…

    Linux 2023年5月24日
    00
  • CentOS7-自动化部署web集群

    一、项目要求 1、创建role,通过role完成项目(可能需要多个role)2、部署nginx调度器(node2主机)3、部署2台lnmp服务器(node3,node4主机)4、部署mariadb数据库(node5主机) 主要用的ansible实现自动化部署,ansible的安装教程省略,控制节点安装ansible和Python,受控节点上只需要安装相同版本…

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