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

yizhihongxing

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系统下文件压缩与打包命令

    常用的压缩文件拓展名 * .Z * .zip * .gz * .bz2 * .xz * .tar * .tar.gz * .tar.bz2 * .tar.xz 压缩命令 gzip,zcat/zmore/zless/zgrep 描述:替换早期的compress命令提供更好压缩比,应用最广的压缩命令,建立出的压缩文件为*.gz gzip [-cdtv#] 文件名…

    Linux 2023年4月11日
    00
  • Linux ifconfig命令

    如果config是熟悉Linux网络配置的工具,是用来查询和配置Linux系统上的网络参数和接口信息的命令行工具。下面,我们来详细讲解 ifconfig 命令的作用与使用方法: 1. 安装 ifconfig 命令是Linux系统上的内置命令,即可用性非常高,一般情况下不需要安装。 2. 作用 ifconfig 用于查询和配置Linux系统上的网络参数和接口信…

    Linux 2023年3月28日
    00
  • 无公网IP远也能远程开发调试 VMware虚拟机端口映射3步实现

    下面是关于“无公网IP远也能远程开发调试 VMware虚拟机端口映射3步实现”的详细攻略。 什么是端口映射 端口映射是指在NAT(网络地址转换)设备上建立内网地址和公网地址之间的端口对应关系,以便内网设备通过公网访问网络。在本文中,我们将通过端口映射来实现远程访问本地的VMware虚拟机。 为什么需要端口映射 由于大部分情况下仅有内网IP,很难便捷地进行远程…

    Linux 2023年5月24日
    00
  • 基于Linux搭建Apache网站服务配置详解

    以下是“基于Linux搭建Apache网站服务配置详解”的完整使用攻略,包含两个示例说明。 步骤 安装Apache服务器。在终端中输入以下命令: bash sudo-get update sudo apt-get install apache2 启动Apache服务器。在终端中输入以下命令: bash sudo service apache2 start 在…

    Linux 2023年5月12日
    00
  • Linux配置为代理服务器,代理微信

    1.安装squid(全程使用root账号,如使用其他请注意权限问题) yum install squid 2.生成代理的账号密码 #如果没有htpasswd命令 先安装sudo yum install httpd-tools #zsp为用户名,按自己实际情况替换 htpasswd -c /etc/squid/passwd zsp 2.配置/etc/squid…

    2023年4月8日
    00
  • Nginx和GeoIP模块读取IP所在的地域信息方法

    下面我将详细讲解如何使用Nginx和GeoIP模块获取IP所在地域信息。 简介 GeoIP是一个由MaxMind提供的IP地理位置查询服务。Nginx的GeoIP模块是Nginx扩展模块之一,可以结合GeoIP数据库获取IP所在国家、地区、城市等信息。 步骤 安装GeoIP库和Nginx的GeoIP模块 首先需要安装GeoIP库和Nginx的GeoIP模块。…

    Linux 2023年5月14日
    00
  • centos下yum搭建安装linux+apache+mysql+php环境教程

    下面是“centos下yum搭建安装linux+apache+mysql+php环境教程”的完整攻略: 一、准备工作 初始化系统:yum update -y 安装必要的工具:yum install -y vim wget net-tools 二、安装Apache 安装Apache:yum install -y httpd 启动Apache:systemctl…

    Linux 2023年5月14日
    00
  • 在Linux上安装和使用Docker的方法

    以下是在Linux上安装和使用Docker的方法的完整攻略: 准备工作 在开始安装和使用Docker之前,你需要满足以下要求: 运行 Linux 系统,版本最好在 3.10 以上,建议使用 Ubuntu 16.04 或更高版本。 拥有 root 用户权限或能够使用 sudo 命令。 确保安装了必要的依赖程序,包括 curl、apt-transport-htt…

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