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技术站