mysql服务

常见的关系型数据库管理系统:

  • MySQL:MySQL,MariaDB,Percona-Server
  • PostgreSQL:简称为pgsql
  • Oracle
  • MSSQL

mysql的安装

  • 源代码:编译安装
  • 二进制格式的程序包:展开至特定路径,并经过简单配置后即可使用
  • 程序包管理器管理的程序包

 配置mysql的yum源

[root@xk ~]# cd /etc/yum.repos.d/
[root@xk yum.repos.d]# ls
[root@xk yum.repos.d]# yum list all|grep mysql
[root@xk yum.repos.d]# cd
[root@xk ~]# rpm -Uvh http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
Retrieving http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
warning: /var/tmp/rpm-tmp.eUeMx4: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql57-community-release-el7-10 ################################# [100%]
[root@xk ~]# ls  /etc/yum.repos.d/
mysql-community.repo  mysql-community-source.repo
[root@xk ~]# yum clean all
15 files removed
[root@xk ~]# yum makecache
MySQL Connectors Community                                              1.4 kB/s |  53 kB     00:38    
MySQL Tools Community                                                   682 kB/s | 778 kB     00:01    
MySQL 5.7 Community Server                                              1.7 MB/s | 2.8 MB     00:01    
Metadata cache created.
[root@xk ~]# yum list all|grep mysql
mysql57-community-release.noarch            el7-10                          @System                   
mysql-community-client.i686                 5.7.40-1.el7                    mysql57-community         
mysql-community-client.x86_64               5.7.40-1.el7                    mysql57-community         
mysql-community-common.i686                 5.7.40-1.el7                    mysql57-community         
mysql-community-common.x86_64               5.7.40-1.el7                    mysql57-community         
mysql-community-devel.i686                  5.7.40-1.el7                    mysql57-community         
mysql-community-devel.x86_64                5.7.40-1.el7                    mysql57-community         
mysql-community-embedded.i686               5.7.40-1.el7                    mysql57-community         
mysql-community-embedded.x86_64             5.7.40-1.el7                    mysql57-community         
mysql-community-embedded-compat.i686        5.7.40-1.el7                    mysql57-community         
mysql-community-embedded-compat.x86_64      5.7.40-1.el7                    mysql57-community         
mysql-community-embedded-devel.i686         5.7.40-1.el7                    mysql57-community         
mysql-community-embedded-devel.x86_64       5.7.40-1.el7                    mysql57-community         
mysql-community-libs.i686                   5.7.40-1.el7                    mysql57-community         
mysql-community-libs.x86_64                 5.7.40-1.el7                    mysql57-community         
mysql-community-libs-compat.i686            5.7.40-1.el7                    mysql57-community         
mysql-community-libs-compat.x86_64          5.7.40-1.el7                    mysql57-community         
mysql-community-release.noarch              el7-5                           mysql-connectors-community
mysql-community-release.noarch              el7-5                           mysql-tools-community     
mysql-community-server.x86_64               5.7.40-1.el7                    mysql57-community         
mysql-community-test.x86_64                 5.7.40-1.el7                    mysql57-community         
mysql-connector-c++.x86_64                  8.0.31-1.el7                    mysql-connectors-community
mysql-connector-c++-devel.x86_64            8.0.31-1.el7                    mysql-connectors-community
mysql-connector-c++-jdbc.x86_64             8.0.31-1.el7                    mysql-connectors-community
mysql-connector-j.noarch                    1:8.0.31-1.el7                  mysql-connectors-community
mysql-connector-java.noarch                 1:8.0.30-1.el7                  mysql-connectors-community
mysql-connector-odbc.x86_64                 8.0.31-1.el7                    mysql-connectors-community
mysql-connector-odbc-setup.x86_64           8.0.31-1.el7                    mysql-connectors-community
mysql-connector-python.noarch               2.0.4-1.el7                     mysql-connectors-community
mysql-connector-python.x86_64               8.0.23-1.el7                    mysql-connectors-community
mysql-connector-python-cext.x86_64          8.0.21-1.el7                    mysql-connectors-community
mysql-connector-python3.x86_64              8.0.31-1.el7                    mysql-connectors-community
mysql-connector-python3-cext.x86_64         8.0.21-1.el7                    mysql-connectors-community
mysql-ref-manual-5.5-en-html-chapter.noarch 1-20170320                      mysql57-community         
mysql-ref-manual-5.5-en-pdf.noarch          1-20170320                      mysql57-community         
mysql-ref-manual-5.7-en-html-chapter.noarch 1-20220831                      mysql57-community         
mysql-ref-manual-5.7-en-pdf.noarch          1-20220831                      mysql57-community         
mysql-router.x86_64                         8.0.12-1.el7                    mysql-tools-community     
mysql-router-community.x86_64               8.0.31-1.el7                    mysql-tools-community     
mysql-shell.x86_64                          8.0.31-1.el7                    mysql-tools-community     
mysql-utilities.noarch                      1.6.5-1.el7                     mysql-tools-community     
mysql-utilities-extra.noarch                1.5.6-1.el7                     mysql-tools-community     
mysql-workbench-community.x86_64            8.0.22-1.

配置阿里云的基础源

[root@xk ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2495  100  2495    0     0  12475      0 --:--:-- --:--:-- --:--:-- 12412
[root@xk ~]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
[root@xk ~]# yum clean all
15 files removed
[root@xk ~]# yum makecache
CentOS-8.5.2111 - Base - mirrors.aliyun.com                             1.5 MB/s | 4.6 MB     00:03    
CentOS-8.5.2111 - Extras - mirrors.aliyun.com                            64 kB/s |  10 kB     00:00    
CentOS-8.5.2111 - AppStream - mirrors.aliyun.com                        2.4 MB/s | 8.4 MB     00:03    
MySQL Connectors Community                                              173 kB/s |  53 kB     00:00    
MySQL Tools Community                                                   1.3 MB/s | 778 kB     00:00    
MySQL 5.7 Community Server                                              2.2 MB/s | 2.8 MB     00:01    
Metadata cache created.
[root@xk ~]# 

安装wget

[root@xk ~]# yum -y install wget
Last metadata expiration check: 0:17:05 ago on Tue 27 Dec 2022 08:37:02 PM CST.
Dependencies resolved.
========================================================================================================
 Package                  Architecture        Version                      Repository              Size
========================================================================================================
Installing:
 wget                     x86_64              1.19.5-10.el8                AppStream              734 k
Installing dependencies:
 libmetalink              x86_64              0.1.3-7.el8                  base                    32 k

Transaction Summary
========================================================================================================
Install  2 Packages

Total download size: 766 k
Installed size: 2.8 M
Downloading Packages:
(1/2): libmetalink-0.1.3-7.el8.x86_64.rpm                               177 kB/s |  32 kB     00:00    
(2/2): wget-1.19.5-10.el8.x86_64.rpm                                    959 kB/s | 734 kB     00:00    
--------------------------------------------------------------------------------------------------------
Total                                                                   999 kB/s | 766 kB     00:00     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                1/1 
  Installing       : libmetalink-0.1.3-7.el8.x86_64                                                 1/2 
  Installing       : wget-1.19.5-10.el8.x86_64                                                      2/2 
  Running scriptlet: wget-1.19.5-10.el8.x86_64                                                      2/2 
  Verifying        : libmetalink-0.1.3-7.el8.x86_64                                                 1/2 
  Verifying        : wget-1.19.5-10.el8.x86_64                                                      2/2 

Installed:
  libmetalink-0.1.3-7.el8.x86_64                        wget-1.19.5-10.el8.x86_64                       

Complete!
[root@xk ~]# 

下载五个包并查看

[root@xk src]# wget http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-client-5.7.40-1.el7.x86_64.rpm http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-common-5.7.40-1.el7.x86_64.rpm http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-devel-5.7.40-1.el7.x86_64.rpm http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-libs-5.7.40-1.el7.x86_64.rpm http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-server-5.7.40-1.el7.x86_64.rpm
--2022-12-27 21:03:17--  http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-client-5.7.40-1.el7.x86_64.rpm
Resolving repo.mysql.com (repo.mysql.com)... 23.36.48.238
Connecting to repo.mysql.com (repo.mysql.com)|23.36.48.238|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 29373184 (28M) [application/x-redhat-package-manager]
Saving to: ‘mysql-community-client-5.7.40-1.el7.x86_64.rpm’

mysql-community-client-5. 100%[=====================================>]  28.01M  3.79MB/s    in 8.3s    

2022-12-27 21:03:25 (3.38 MB/s) - ‘mysql-community-client-5.7.40-1.el7.x86_64.rpm’ saved [29373184/29373184]

--2022-12-27 21:03:25--  http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-common-5.7.40-1.el7.x86_64.rpm
Reusing existing connection to repo.mysql.com:80.
HTTP request sent, awaiting response... 200 OK
Length: 318744 (311K) [application/x-redhat-package-manager]
Saving to: ‘mysql-community-common-5.7.40-1.el7.x86_64.rpm’

mysql-community-common-5. 100%[=====================================>] 311.27K  --.-KB/s    in 0.07s   

2022-12-27 21:03:26 (4.30 MB/s) - ‘mysql-community-common-5.7.40-1.el7.x86_64.rpm’ saved [318744/318744]

--2022-12-27 21:03:26--  http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-devel-5.7.40-1.el7.x86_64.rpm
Reusing existing connection to repo.mysql.com:80.
HTTP request sent, awaiting response... 200 OK
Length: 4426916 (4.2M) [application/x-redhat-package-manager]
Saving to: ‘mysql-community-devel-5.7.40-1.el7.x86_64.rpm’

mysql-community-devel-5.7 100%[=====================================>]   4.22M  5.36MB/s    in 0.8s    

2022-12-27 21:03:26 (5.36 MB/s) - ‘mysql-community-devel-5.7.40-1.el7.x86_64.rpm’ saved [4426916/4426916]

--2022-12-27 21:03:26--  http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-libs-5.7.40-1.el7.x86_64.rpm
Reusing existing connection to repo.mysql.com:80.
HTTP request sent, awaiting response... 200 OK
Length: 2744456 (2.6M) [application/x-redhat-package-manager]
Saving to: ‘mysql-community-libs-5.7.40-1.el7.x86_64.rpm’

mysql-community-libs-5.7. 100%[=====================================>]   2.62M  5.91MB/s    in 0.4s    

2022-12-27 21:03:27 (5.91 MB/s) - ‘mysql-community-libs-5.7.40-1.el7.x86_64.rpm’ saved [2744456/2744456]

--2022-12-27 21:03:27--  http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-server-5.7.40-1.el7.x86_64.rpm
Reusing existing connection to repo.mysql.com:80.
HTTP request sent, awaiting response... 200 OK
Length: 187168492 (178M) [application/x-redhat-package-manager]
Saving to: ‘mysql-community-server-5.7.40-1.el7.x86_64.rpm’

mysql-community-server-5. 100%[=====================================>] 178.50M  3.78MB/s    in 51s     

2022-12-27 21:04:18 (3.49 MB/s) - ‘mysql-community-server-5.7.40-1.el7.x86_64.rpm’ saved [187168492/187168492]

FINISHED --2022-12-27 21:04:18--
Total wall clock time: 1m 1s
Downloaded: 5 files, 214M in 1m 1s (3.52 MB/s)
[root@xk src]# ls
debug                                           mysql-community-devel-5.7.40-1.el7.x86_64.rpm
kernels                                         mysql-community-libs-5.7.40-1.el7.x86_64.rpm
mysql-community-client-5.7.40-1.el7.x86_64.rpm  mysql-community-server-5.7.40-1.el7.x86_64.rpm
mysql-community-common-5.7.40-1.el7.x86_64.rpm

vim编辑修改为x86-64

[root@xk src]# cd
[root@xk ~]# cd /etc/yum.repos.d/
[root@xk yum.repos.d]# ls
CentOS-Base.repo  mysql-community.repo  mysql-community-source.repo
[root@xk yum.repos.d]# yum -y install vim
Last metadata expiration check: 0:31:01 ago on Tue 27 Dec 2022 08:37:02 PM CST.
Package vim-enhanced-2:8.0.1763-16.el8.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!
[root@xk yum.repos.d]# vim mysql-community.repo 

[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

清理缓存重建

[root@xk ~]# yum clean all
33 files removed
[root@xk ~]# yum makecache
CentOS-8.5.2111 - Base - mirrors.aliyun.com                             3.2 MB/s | 4.6 MB     00:01    
CentOS-8.5.2111 - Extras - mirrors.aliyun.com                            59 kB/s |  10 kB     00:00    
CentOS-8.5.2111 - AppStream - mirrors.aliyun.com                        2.4 MB/s | 8.4 MB     00:03    
MySQL Connectors Community                                              107 kB/s |  53 kB     00:00    
MySQL Tools Community                                                   761 kB/s | 778 kB     00:01    
MySQL 5.7 Community Server                                              1.5 MB/s | 2.8 MB     00:01    
Metadata cache created.
[root@xk src]# yum -y localinstall *.rpm
Last metadata expiration check: 0:04:23 ago on Tue 27 Dec 2022 09:13:22 PM CST.
Dependencies resolved.
========================================================================================================
 Package                   Arch      Version                                      Repository       Size
========================================================================================================
Installing:
 mysql-community-client    x86_64    5.7.40-1.el7                                 @commandline     28 M
 mysql-community-common    x86_64    5.7.40-1.el7                                 @commandline    311 k
 mysql-community-devel     x86_64    5.7.40-1.el7                                 @commandline    4.2 M
 mysql-community-libs      x86_64    5.7.40-1.el7                                 @commandline    2.6 M
 mysql-community-server    x86_64    5.7.40-1.el7                                 @commandline    178 M
Installing dependencies:
 libpkgconf                x86_64    1.4.2-1.el8                                  base             35 k
 ncurses-compat-libs       x86_64    6.1-9.20180224.el8                           base            328 k
 net-tools                 x86_64    2.0-0.52.20160912git.el8                     base            322 k
 perl-Carp                 noarch    1.42-396.el8                                 base             30 k
 perl-Data-Dumper          x86_64    2.167-399.el8                                base             58 k
 perl-Digest               noarch    1.17-395.el8                                 AppStream        27 k
 perl-Digest-MD5           x86_64    2.55-396.el8                                 AppStream        37 k
 perl-Encode               x86_64    4:2.97-3.el8                                 base            1.5 M
 perl-Errno                x86_64    1.28-420.el8                                 base             76 k
 perl-Exporter             noarch    5.72-396.el8                                 base             34 k
 perl-File-Path            noarch    2.15-2.el8                                   base             38 k
 perl-File-Temp            noarch    0.230.600-1.el8                              base             63 k
 perl-Getopt-Long          noarch    1:2.50-4.el8                                 base             63 k
 perl-HTTP-Tiny            noarch    0.074-1.el8                                  base             58 k
 perl-IO                   x86_64    1.38-420.el8                                 base            142 k
 perl-MIME-Base64          x86_64    3.15-396.el8                                 base             31 k
 perl-Net-SSLeay           x86_64    1.88-1.module_el8.3.0+410+ff426aa3           AppStream       379 k
 perl-PathTools            x86_64    3.74-1.el8                                   base             90 k
 perl-Pod-Escapes          noarch    1:1.07-395.el8                               base             20 k
 perl-Pod-Perldoc          noarch    3.28-396.el8                                 base             86 k
 perl-Pod-Simple           noarch    1:3.35-395.el8                               base            213 k
 perl-Pod-Usage            noarch    4:1.69-395.el8                               base             34 k
 perl-Scalar-List-Utils    x86_64    3:1.49-2.el8                                 base             68 k
 perl-Socket               x86_64    4:2.027-3.el8                                base             59 k
 perl-Storable             x86_64    1:3.11-3.el8                                 base             98 k
 perl-Term-ANSIColor       noarch    4.06-396.el8                                 base             46 k
 perl-Term-Cap             noarch    1.17-395.el8                                 base             23 k
 perl-Text-ParseWords      noarch    3.30-395.el8                                 base             18 k
 perl-Text-Tabs+Wrap       noarch    2013.0523-395.el8                            base             24 k
 perl-Time-Local           noarch    1:1.280-1.el8                                base             34 k
 perl-URI                  noarch    1.73-3.el8                                   AppStream       116 k
 perl-Unicode-Normalize    x86_64    1.25-396.el8                                 base             82 k
 perl-constant             noarch    1.33-396.el8                                 base             25 k
 perl-interpreter          x86_64    4:5.26.3-420.el8                             base            6.3 M
 perl-libnet               noarch    3.11-3.el8                                   AppStream       121 k
 perl-libs                 x86_64    4:5.26.3-420.el8                             base            1.6 M
 perl-macros               x86_64    4:5.26.3-420.el8                             base             72 k
 perl-parent               noarch    1:0.237-1.el8                                base             20 k
 perl-podlators            noarch    4.11-1.el8                                   base            118 k
 perl-threads              x86_64    1:2.21-2.el8                                 base             61 k
 perl-threads-shared       x86_64    1.58-2.el8                                   base             48 k
 pkgconf                   x86_64    1.4.2-1.el8                                  base             38 k
 pkgconf-m4                noarch    1.4.2-1.el8                                  base             17 k
 pkgconf-pkg-config        x86_64    1.4.2-1.el8                                  base             15 k
Installing weak dependencies:
 perl-IO-Socket-IP         noarch    0.39-5.el8                                   AppStream        47 k
 perl-IO-Socket-SSL        noarch    2.066-4.module_el8.3.0+410+ff426aa3          AppStream       298 k
 perl-Mozilla-CA           noarch    20160104-7.module_el8.3.0+416+dee7bcef       AppStream        15 k
Enabling module streams:
 perl                                5.26                                                              
 perl-IO-Socket-SSL                  2.066                                                             
 perl-libwww-perl                    6.34                                                              

Transaction Summary
========================================================================================================
Install  52 Packages

Total size: 227 M
Total download size: 13 M
Installed size: 956 M
Downloading Packages:
(1/47): libpkgconf-1.4.2-1.el8.x86_64.rpm                               6.7 kB/s |  35 kB     00:05    
(2/47): ncurses-compat-libs-6.1-9.20180224.el8.x86_64.rpm                60 kB/s | 328 kB     00:05    
(3/47): net-tools-2.0-0.52.20160912git.el8.x86_64.rpm                    58 kB/s | 322 kB     00:05    
(4/47): perl-Data-Dumper-2.167-399.el8.x86_64.rpm                       387 kB/s |  58 kB     00:00    
(5/47): perl-Carp-1.42-396.el8.noarch.rpm                                68 kB/s |  30 kB     00:00    
(6/47): perl-Exporter-5.72-396.el8.noarch.rpm                           199 kB/s |  34 kB     00:00    
(7/47): perl-Errno-1.28-420.el8.x86_64.rpm                              422 kB/s |  76 kB     00:00    
(8/47): perl-File-Path-2.15-2.el8.noarch.rpm                            182 kB/s |  38 kB     00:00    
(9/47): perl-File-Temp-0.230.600-1.el8.noarch.rpm                       310 kB/s |  63 kB     00:00    
(10/47): perl-HTTP-Tiny-0.074-1.el8.noarch.rpm                          352 kB/s |  58 kB     00:00    
(11/47): perl-IO-1.38-420.el8.x86_64.rpm                                961 kB/s | 142 kB     00:00    
(12/47): perl-Getopt-Long-2.50-4.el8.noarch.rpm                         189 kB/s |  63 kB     00:00    
(13/47): perl-MIME-Base64-3.15-396.el8.x86_64.rpm                       154 kB/s |  31 kB     00:00    
(14/47): perl-PathTools-3.74-1.el8.x86_64.rpm                           465 kB/s |  90 kB     00:00    
(15/47): perl-Encode-2.97-3.el8.x86_64.rpm                              1.3 MB/s | 1.5 MB     00:01    
(16/47): perl-Pod-Escapes-1.07-395.el8.noarch.rpm                       118 kB/s |  20 kB     00:00    
(17/47): perl-Pod-Perldoc-3.28-396.el8.noarch.rpm                       473 kB/s |  86 kB     00:00    
(18/47): perl-Pod-Usage-1.69-395.el8.noarch.rpm                         245 kB/s |  34 kB     00:00    
(19/47): perl-Scalar-List-Utils-1.49-2.el8.x86_64.rpm                   310 kB/s |  68 kB     00:00    
(20/47): perl-Pod-Simple-3.35-395.el8.noarch.rpm                        836 kB/s | 213 kB     00:00    
(21/47): perl-Socket-2.027-3.el8.x86_64.rpm                             547 kB/s |  59 kB     00:00    
(22/47): perl-Term-ANSIColor-4.06-396.el8.noarch.rpm                    249 kB/s |  46 kB     00:00    
(23/47): perl-Term-Cap-1.17-395.el8.noarch.rpm                          102 kB/s |  23 kB     00:00    
(24/47): perl-Storable-3.11-3.el8.x86_64.rpm                            343 kB/s |  98 kB     00:00    
(25/47): perl-Text-ParseWords-3.30-395.el8.noarch.rpm                   143 kB/s |  18 kB     00:00    
(26/47): perl-Text-Tabs+Wrap-2013.0523-395.el8.noarch.rpm               187 kB/s |  24 kB     00:00    
(27/47): perl-Unicode-Normalize-1.25-396.el8.x86_64.rpm                 710 kB/s |  82 kB     00:00    
(28/47): perl-constant-1.33-396.el8.noarch.rpm                          234 kB/s |  25 kB     00:00    
(29/47): perl-Time-Local-1.280-1.el8.noarch.rpm                         146 kB/s |  34 kB     00:00    
(30/47): perl-macros-5.26.3-420.el8.x86_64.rpm                          221 kB/s |  72 kB     00:00    
(31/47): perl-parent-0.237-1.el8.noarch.rpm                              98 kB/s |  20 kB     00:00    
(32/47): perl-podlators-4.11-1.el8.noarch.rpm                           423 kB/s | 118 kB     00:00    
(33/47): perl-threads-2.21-2.el8.x86_64.rpm                             269 kB/s |  61 kB     00:00    
(34/47): perl-libs-5.26.3-420.el8.x86_64.rpm                            1.2 MB/s | 1.6 MB     00:01    
(35/47): perl-threads-shared-1.58-2.el8.x86_64.rpm                      233 kB/s |  48 kB     00:00    
(36/47): pkgconf-1.4.2-1.el8.x86_64.rpm                                 359 kB/s |  38 kB     00:00    
(37/47): pkgconf-m4-1.4.2-1.el8.noarch.rpm                              129 kB/s |  17 kB     00:00    
(38/47): pkgconf-pkg-config-1.4.2-1.el8.x86_64.rpm                      154 kB/s |  15 kB     00:00    
(39/47): perl-Digest-1.17-395.el8.noarch.rpm                            233 kB/s |  27 kB     00:00    
(40/47): perl-Digest-MD5-2.55-396.el8.x86_64.rpm                        284 kB/s |  37 kB     00:00    
(41/47): perl-IO-Socket-IP-0.39-5.el8.noarch.rpm                        250 kB/s |  47 kB     00:00    
(42/47): perl-Mozilla-CA-20160104-7.module_el8.3.0+416+dee7bcef.noarch.  77 kB/s |  15 kB     00:00    
(43/47): perl-IO-Socket-SSL-2.066-4.module_el8.3.0+410+ff426aa3.noarch. 650 kB/s | 298 kB     00:00    
(44/47): perl-URI-1.73-3.el8.noarch.rpm                                 494 kB/s | 116 kB     00:00    
(45/47): perl-Net-SSLeay-1.88-1.module_el8.3.0+410+ff426aa3.x86_64.rpm  799 kB/s | 379 kB     00:00    
(46/47): perl-libnet-3.11-3.el8.noarch.rpm                              590 kB/s | 121 kB     00:00    
(47/47): perl-interpreter-5.26.3-420.el8.x86_64.rpm                     1.5 MB/s | 6.3 MB     00:04    
--------------------------------------------------------------------------------------------------------
Total                                                                   1.1 MB/s |  13 MB     00:11     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                1/1 
  Installing       : perl-Digest-1.17-395.el8.noarch                                               1/52 
  Installing       : perl-Digest-MD5-2.55-396.el8.x86_64                                           2/52 
  Installing       : perl-Data-Dumper-2.167-399.el8.x86_64                                         3/52 
  Installing       : perl-libnet-3.11-3.el8.noarch                                                 4/52 
  Installing       : perl-Net-SSLeay-1.88-1.module_el8.3.0+410+ff426aa3.x86_64                     5/52 
  Installing       : perl-URI-1.73-3.el8.noarch                                                    6/52 
  Installing       : perl-Pod-Escapes-1:1.07-395.el8.noarch                                        7/52 
  Installing       : perl-Time-Local-1:1.280-1.el8.noarch                                          8/52 
  Installing       : perl-IO-Socket-IP-0.39-5.el8.noarch                                           9/52 
  Installing       : perl-Mozilla-CA-20160104-7.module_el8.3.0+416+dee7bcef.noarch                10/52 
  Installing       : perl-IO-Socket-SSL-2.066-4.module_el8.3.0+410+ff426aa3.noarch                11/52 
  Installing       : perl-Term-ANSIColor-4.06-396.el8.noarch                                      12/52 
  Installing       : perl-Term-Cap-1.17-395.el8.noarch                                            13/52 
  Installing       : perl-File-Temp-0.230.600-1.el8.noarch                                        14/52 
  Installing       : perl-Pod-Simple-1:3.35-395.el8.noarch                                        15/52 
  Installing       : perl-HTTP-Tiny-0.074-1.el8.noarch                                            16/52 
  Installing       : perl-podlators-4.11-1.el8.noarch                                             17/52 
  Installing       : perl-Pod-Perldoc-3.28-396.el8.noarch                                         18/52 
  Installing       : perl-Text-ParseWords-3.30-395.el8.noarch                                     19/52 
  Installing       : perl-Pod-Usage-4:1.69-395.el8.noarch                                         20/52 
  Installing       : perl-MIME-Base64-3.15-396.el8.x86_64                                         21/52 
  Installing       : perl-Storable-1:3.11-3.el8.x86_64                                            22/52 
  Installing       : perl-Getopt-Long-1:2.50-4.el8.noarch                                         23/52 
  Installing       : perl-Errno-1.28-420.el8.x86_64                                               24/52 
  Installing       : perl-Socket-4:2.027-3.el8.x86_64                                             25/52 
  Installing       : perl-Encode-4:2.97-3.el8.x86_64                                              26/52 
  Installing       : perl-Exporter-5.72-396.el8.noarch                                            27/52 
  Installing       : perl-Scalar-List-Utils-3:1.49-2.el8.x86_64                                   28/52 
  Installing       : perl-macros-4:5.26.3-420.el8.x86_64                                          29/52 
  Installing       : perl-parent-1:0.237-1.el8.noarch                                             30/52 
  Installing       : perl-Text-Tabs+Wrap-2013.0523-395.el8.noarch                                 31/52 
  Installing       : perl-Unicode-Normalize-1.25-396.el8.x86_64                                   32/52 
  Installing       : perl-File-Path-2.15-2.el8.noarch                                             33/52 
  Installing       : perl-IO-1.38-420.el8.x86_64                                                  34/52 
  Installing       : perl-PathTools-3.74-1.el8.x86_64                                             35/52 
  Installing       : perl-constant-1.33-396.el8.noarch                                            36/52 
  Installing       : perl-threads-1:2.21-2.el8.x86_64                                             37/52 
  Installing       : perl-threads-shared-1.58-2.el8.x86_64                                        38/52 
  Installing       : perl-libs-4:5.26.3-420.el8.x86_64                                            39/52 
  Installing       : perl-Carp-1.42-396.el8.noarch                                                40/52 
  Installing       : perl-interpreter-4:5.26.3-420.el8.x86_64                                     41/52 
  Installing       : mysql-community-common-5.7.40-1.el7.x86_64                                   42/52 
  Installing       : mysql-community-libs-5.7.40-1.el7.x86_64                                     43/52 
  Running scriptlet: mysql-community-libs-5.7.40-1.el7.x86_64                                     43/52 
  Installing       : pkgconf-m4-1.4.2-1.el8.noarch                                                44/52 
  Installing       : net-tools-2.0-0.52.20160912git.el8.x86_64                                    45/52 
  Running scriptlet: net-tools-2.0-0.52.20160912git.el8.x86_64                                    45/52 
  Installing       : ncurses-compat-libs-6.1-9.20180224.el8.x86_64                                46/52 
  Installing       : mysql-community-client-5.7.40-1.el7.x86_64                                   47/52 
  Installing       : libpkgconf-1.4.2-1.el8.x86_64                                                48/52 
  Installing       : pkgconf-1.4.2-1.el8.x86_64                                                   49/52 
  Installing       : pkgconf-pkg-config-1.4.2-1.el8.x86_64                                        50/52 
  Installing       : mysql-community-devel-5.7.40-1.el7.x86_64                                    51/52 
  Running scriptlet: mysql-community-server-5.7.40-1.el7.x86_64                                   52/52 
  Installing       : mysql-community-server-5.7.40-1.el7.x86_64                                   52/52 
  Running scriptlet: mysql-community-server-5.7.40-1.el7.x86_64                                   52/52 
[/usr/lib/tmpfiles.d/mysql.conf:23] Line references path below legacy directory /var/run/, updating /var/run/mysqld → /run/mysqld; please update the tmpfiles.d/ drop-in file accordingly.

  Verifying        : libpkgconf-1.4.2-1.el8.x86_64                                                 1/52 
  Verifying        : ncurses-compat-libs-6.1-9.20180224.el8.x86_64                                 2/52 
  Verifying        : net-tools-2.0-0.52.20160912git.el8.x86_64                                     3/52 
  Verifying        : perl-Carp-1.42-396.el8.noarch                                                 4/52 
  Verifying        : perl-Data-Dumper-2.167-399.el8.x86_64                                         5/52 
  Verifying        : perl-Encode-4:2.97-3.el8.x86_64                                               6/52 
  Verifying        : perl-Errno-1.28-420.el8.x86_64                                                7/52 
  Verifying        : perl-Exporter-5.72-396.el8.noarch                                             8/52 
  Verifying        : perl-File-Path-2.15-2.el8.noarch                                              9/52 
  Verifying        : perl-File-Temp-0.230.600-1.el8.noarch                                        10/52 
  Verifying        : perl-Getopt-Long-1:2.50-4.el8.noarch                                         11/52 
  Verifying        : perl-HTTP-Tiny-0.074-1.el8.noarch                                            12/52 
  Verifying        : perl-IO-1.38-420.el8.x86_64                                                  13/52 
  Verifying        : perl-MIME-Base64-3.15-396.el8.x86_64                                         14/52 
  Verifying        : perl-PathTools-3.74-1.el8.x86_64                                             15/52 
  Verifying        : perl-Pod-Escapes-1:1.07-395.el8.noarch                                       16/52 
  Verifying        : perl-Pod-Perldoc-3.28-396.el8.noarch                                         17/52 
  Verifying        : perl-Pod-Simple-1:3.35-395.el8.noarch                                        18/52 
  Verifying        : perl-Pod-Usage-4:1.69-395.el8.noarch                                         19/52 
  Verifying        : perl-Scalar-List-Utils-3:1.49-2.el8.x86_64                                   20/52 
  Verifying        : perl-Socket-4:2.027-3.el8.x86_64                                             21/52 
  Verifying        : perl-Storable-1:3.11-3.el8.x86_64                                            22/52 
  Verifying        : perl-Term-ANSIColor-4.06-396.el8.noarch                                      23/52 
  Verifying        : perl-Term-Cap-1.17-395.el8.noarch                                            24/52 
  Verifying        : perl-Text-ParseWords-3.30-395.el8.noarch                                     25/52 
  Verifying        : perl-Text-Tabs+Wrap-2013.0523-395.el8.noarch                                 26/52 
  Verifying        : perl-Time-Local-1:1.280-1.el8.noarch                                         27/52 
  Verifying        : perl-Unicode-Normalize-1.25-396.el8.x86_64                                   28/52 
  Verifying        : perl-constant-1.33-396.el8.noarch                                            29/52 
  Verifying        : perl-interpreter-4:5.26.3-420.el8.x86_64                                     30/52 
  Verifying        : perl-libs-4:5.26.3-420.el8.x86_64                                            31/52 
  Verifying        : perl-macros-4:5.26.3-420.el8.x86_64                                          32/52 
  Verifying        : perl-parent-1:0.237-1.el8.noarch                                             33/52 
  Verifying        : perl-podlators-4.11-1.el8.noarch                                             34/52 
  Verifying        : perl-threads-1:2.21-2.el8.x86_64                                             35/52 
  Verifying        : perl-threads-shared-1.58-2.el8.x86_64                                        36/52 
  Verifying        : pkgconf-1.4.2-1.el8.x86_64                                                   37/52 
  Verifying        : pkgconf-m4-1.4.2-1.el8.noarch                                                38/52 
  Verifying        : pkgconf-pkg-config-1.4.2-1.el8.x86_64                                        39/52 
  Verifying        : perl-Digest-1.17-395.el8.noarch                                              40/52 
  Verifying        : perl-Digest-MD5-2.55-396.el8.x86_64                                          41/52 
  Verifying        : perl-IO-Socket-IP-0.39-5.el8.noarch                                          42/52 
  Verifying        : perl-IO-Socket-SSL-2.066-4.module_el8.3.0+410+ff426aa3.noarch                43/52 
  Verifying        : perl-Mozilla-CA-20160104-7.module_el8.3.0+416+dee7bcef.noarch                44/52 
  Verifying        : perl-Net-SSLeay-1.88-1.module_el8.3.0+410+ff426aa3.x86_64                    45/52 
  Verifying        : perl-URI-1.73-3.el8.noarch                                                   46/52 
  Verifying        : perl-libnet-3.11-3.el8.noarch                                                47/52 
  Verifying        : mysql-community-client-5.7.40-1.el7.x86_64                                   48/52 
  Verifying        : mysql-community-common-5.7.40-1.el7.x86_64                                   49/52 
  Verifying        : mysql-community-devel-5.7.40-1.el7.x86_64                                    50/52 
  Verifying        : mysql-community-libs-5.7.40-1.el7.x86_64                                     51/52 
  Verifying        : mysql-community-server-5.7.40-1.el7.x86_64                                   52/52 

Installed:
  libpkgconf-1.4.2-1.el8.x86_64                                                                         
  mysql-community-client-5.7.40-1.el7.x86_64                                                            
  mysql-community-common-5.7.40-1.el7.x86_64                                                            
  mysql-community-devel-5.7.40-1.el7.x86_64                                                             
  mysql-community-libs-5.7.40-1.el7.x86_64                                                              
  mysql-community-server-5.7.40-1.el7.x86_64                                                            
  ncurses-compat-libs-6.1-9.20180224.el8.x86_64                                                         
  net-tools-2.0-0.52.20160912git.el8.x86_64                                                             
  perl-Carp-1.42-396.el8.noarch                                                                         
  perl-Data-Dumper-2.167-399.el8.x86_64                                                                 
  perl-Digest-1.17-395.el8.noarch                                                                       
  perl-Digest-MD5-2.55-396.el8.x86_64                                                                   
  perl-Encode-4:2.97-3.el8.x86_64                                                                       
  perl-Errno-1.28-420.el8.x86_64                                                                        
  perl-Exporter-5.72-396.el8.noarch                                                                     
  perl-File-Path-2.15-2.el8.noarch                                                                      
  perl-File-Temp-0.230.600-1.el8.noarch                                                                 
  perl-Getopt-Long-1:2.50-4.el8.noarch                                                                  
  perl-HTTP-Tiny-0.074-1.el8.noarch                                                                     
  perl-IO-1.38-420.el8.x86_64                                                                           
  perl-IO-Socket-IP-0.39-5.el8.noarch                                                                   
  perl-IO-Socket-SSL-2.066-4.module_el8.3.0+410+ff426aa3.noarch                                         
  perl-MIME-Base64-3.15-396.el8.x86_64                                                                  
  perl-Mozilla-CA-20160104-7.module_el8.3.0+416+dee7bcef.noarch                                         
  perl-Net-SSLeay-1.88-1.module_el8.3.0+410+ff426aa3.x86_64                                             
  perl-PathTools-3.74-1.el8.x86_64                                                                      
  perl-Pod-Escapes-1:1.07-395.el8.noarch                                                                
  perl-Pod-Perldoc-3.28-396.el8.noarch                                                                  
  perl-Pod-Simple-1:3.35-395.el8.noarch                                                                 
  perl-Pod-Usage-4:1.69-395.el8.noarch                                                                  
  perl-Scalar-List-Utils-3:1.49-2.el8.x86_64                                                            
  perl-Socket-4:2.027-3.el8.x86_64                                                                      
  perl-Storable-1:3.11-3.el8.x86_64                                                                     
  perl-Term-ANSIColor-4.06-396.el8.noarch                                                               
  perl-Term-Cap-1.17-395.el8.noarch                                                                     
  perl-Text-ParseWords-3.30-395.el8.noarch                                                              
  perl-Text-Tabs+Wrap-2013.0523-395.el8.noarch                                                          
  perl-Time-Local-1:1.280-1.el8.noarch                                                                  
  perl-URI-1.73-3.el8.noarch                                                                            
  perl-Unicode-Normalize-1.25-396.el8.x86_64                                                            
  perl-constant-1.33-396.el8.noarch                                                                     
  perl-interpreter-4:5.26.3-420.el8.x86_64                                                              
  perl-libnet-3.11-3.el8.noarch                                                                         
  perl-libs-4:5.26.3-420.el8.x86_64                                                                     
  perl-macros-4:5.26.3-420.el8.x86_64                                                                   
  perl-parent-1:0.237-1.el8.noarch                                                                      
  perl-podlators-4.11-1.el8.noarch                                                                      
  perl-threads-1:2.21-2.el8.x86_64                                                                      
  perl-threads-shared-1.58-2.el8.x86_64                                                                 
  pkgconf-1.4.2-1.el8.x86_64                                                                            
  pkgconf-m4-1.4.2-1.el8.noarch                                                                         
  pkgconf-pkg-config-1.4.2-1.el8.x86_64                                                                 

Complete!

查看服务已存在

[root@xk src]# cd
[root@xk ~]# systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html

关闭防火墙

[root@xk ~]# systemctl disable --now firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@xk ~]# vim /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted
[root@xk ~]# setenforce 0

临时启动和开机自启

[root@xk ~]# systemctl start  mysqld
[root@xk ~]# systemctl enable  mysqld

查看发现已经启动且开机自启

[root@xk ~]# systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2022-12-27 21:24:42 CST; 1min 34s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
 Main PID: 27371 (mysqld)
    Tasks: 27 (limit: 5790)
   Memory: 286.8M
   CGroup: /system.slice/mysqld.service
           └─27371 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid

Dec 27 21:24:40 xk systemd[1]: Starting MySQL Server...
Dec 27 21:24:42 xk systemd[1]: Started MySQL Server.

端口号3066已经监听

[root@xk ~]# ss -antl
State       Recv-Q      Send-Q           Local Address:Port           Peer Address:Port     Process     
LISTEN      0           128                    0.0.0.0:22                  0.0.0.0:*                    
LISTEN      0           80                           *:3306                      *:*                    
LISTEN      0           128                       [::]:22                     [::]:*  

 在日志找到临时密码

[root@xk ~]# grep password /var/log/mysqld.log 
2022-12-27T13:24:40.769060Z 1 [Note] A temporary password is generated for root@localhost: <kh7Y19bHJqJ

用获取的密码临时登录mysql

[root@xk ~]# mysql -urroot -p'<kh7Y19bHJqJ'
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'rroot'@'localhost' (using password: YES)
[root@xk ~]# mysql -uroot -p'<kh7Y19bHJqJ'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.40

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

改密码

mysql> set password = password("Xukang123!");
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> quit
Bye

验证密码是否设置成功

[root@xk ~]# mysql -uroot -p'Xukang123!'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.40 MySQL Community Server (GPL)

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

删掉yum源和多余文件

[root@xk ~]# rpm -qa|grep mysql
mysql-community-libs-5.7.40-1.el7.x86_64
mysql-community-client-5.7.40-1.el7.x86_64
mysql-community-devel-5.7.40-1.el7.x86_64
mysql57-community-release-el7-10.noarch
mysql-community-common-5.7.40-1.el7.x86_64
mysql-community-server-5.7.40-1.el7.x86_64
[root@xk ~]# rpm -e mysql57-community-release-el7-10.noarch
warning: /etc/yum.repos.d/mysql-community.repo saved as /etc/yum.repos.d/mysql-community.repo.rpmsave
[root@xk ~]# rpm -qa|grep mysql
mysql-community-libs-5.7.40-1.el7.x86_64
mysql-community-client-5.7.40-1.el7.x86_64
mysql-community-devel-5.7.40-1.el7.x86_64
mysql-community-common-5.7.40-1.el7.x86_64
mysql-community-server-5.7.40-1.el7.x86_64
[root@xk ~]# cd /etc/yum.repos.d/
[root@xk yum.repos.d]# ls
CentOS-Base.repo  mysql-community.repo.rpmsave
[root@xk yum.repos.d]# rm -f mysql-community.repo.rpmsave
[root@xk yum.repos.d]# ls
CentOS-Base.repo
[root@xk yum.repos.d]# 

设置安全初始化

[root@xk ~]# mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root: 
The 'validate_password' plugin is installed on the server.
The subsequent steps will run with the existing configuration
of the plugin.
Using existing password for root.

Estimated strength of the password: 100 
Change the password for root ? ((Press y|Y for Yes, any other key for No) : n

 ... skipping.
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

 ... 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
 - 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! 

再次验证

[root@xk ~]# mysql -uroot -p'Xukang123!'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.7.40 MySQL Community Server (GPL)

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

测试链接

给予权限

mysql> grant all on *.* to 'root'@'192.168.154.1' identified by 'Xukang123!';
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> 

使用workbeach远程登录

使用Navicat远程登录

 

成功 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值