centos 7.6 安装mysql 5.7.35

centos 7.6 安装mysql 5.7.35

  • 1、下载mysql安装包
  • 2、安装文档
  • 3、安装MySQL包
  • 4、安装后形成的配置文件和程序位置
  • 5、安装后设置
    • 5.1、修改MySQL root账户默认密码
    • 5.2、关闭系统防火墙
  • 6、使用mysql 5.7.35 数据库
    • 6.1、命令行登录MySQL 5.7.35 数据库
    • 6.2、navicat连接mysql 5.7.35 数据库
    • 6.3、mysql数据库常用命令<5.7.35版本>
      • 6.3.1、初始化默认数据库

1、下载mysql安装包

访问官方下载页面下载bundle安装包
https://downloads.mysql.com/archives/community/

文件名:mysql-5.7.35-1.el7.x86_64.rpm-bundle.tar
MD5: 99c03ce2fe9c57d3f76f59f7211be900

centos 7.6 安装mysql 5.7.35_第1张图片

下载文件 然后解压

mkdir -p /root/package/mysql/mysql-5.7.35-1.el7.x86_64.rpm-bundle
cd /root/package/mysql/
tar -xvf mysql-5.7.35-1.el7.x86_64.rpm-bundle.tar -C mysql-5.7.35-1.el7.x86_64.rpm-bundle

解压后的文件如图

[root@centos mysql]# tar -xvf mysql-5.7.35-1.el7.x86_64.rpm-bundle.tar -C mysql-5.7.35-1.el7.x86_64.rpm-bundle
mysql-community-client-5.7.35-1.el7.x86_64.rpm
mysql-community-common-5.7.35-1.el7.x86_64.rpm
mysql-community-devel-5.7.35-1.el7.x86_64.rpm
mysql-community-embedded-5.7.35-1.el7.x86_64.rpm
mysql-community-embedded-compat-5.7.35-1.el7.x86_64.rpm
mysql-community-embedded-devel-5.7.35-1.el7.x86_64.rpm
mysql-community-libs-5.7.35-1.el7.x86_64.rpm
mysql-community-libs-compat-5.7.35-1.el7.x86_64.rpm
mysql-community-server-5.7.35-1.el7.x86_64.rpm
mysql-community-test-5.7.35-1.el7.x86_64.rpm
[root@centos mysql]# 

2、安装文档

https://dev.mysql.com/doc/refman/5.7/en/linux-installation-rpm.html

3、安装MySQL包

查看包文件

root@debian:~/package/mysql/mysql-server_5.7.41-1debian10_amd64.deb-bundle# ls -lh
total 159M
-rw-r--r-- 1 7155 31415 1.8M Dec  7 12:50 libmysqlclient20_5.7.41-1debian10_amd64.deb
-rw-r--r-- 1 7155 31415 2.3M Dec  7 12:51 libmysqlclient-dev_5.7.41-1debian10_amd64.deb
-rw-r--r-- 1 7155 31415  20M Dec  7 12:50 libmysqld-dev_5.7.41-1debian10_amd64.deb
-rw-r--r-- 1 7155 31415  69K Dec  7 12:50 mysql-client_5.7.41-1debian10_amd64.deb
-rw-r--r-- 1 7155 31415  72K Dec  7 12:50 mysql-common_5.7.41-1debian10_amd64.deb
-rw-r--r-- 1 7155 31415  15M Dec  7 12:50 mysql-community-client_5.7.41-1debian10_amd64.deb
-rw-r--r-- 1 7155 31415  38M Dec  7 12:50 mysql-community-server_5.7.41-1debian10_amd64.deb
-rw-r--r-- 1 7155 31415  52M Dec  7 12:50 mysql-community-source_5.7.41-1debian10_amd64.deb
-rw-r--r-- 1 7155 31415  32M Dec  7 12:50 mysql-community-test_5.7.41-1debian10_amd64.deb
-rw-r--r-- 1 7155 31415  69K Dec  7 12:51 mysql-server_5.7.41-1debian10_amd64.deb
-rw-r--r-- 1 7155 31415  69K Dec  7 12:50 mysql-testsuite_5.7.41-1debian10_amd64.deb
root@debian:~/package/mysql/mysql-server_5.7.41-1debian10_amd64.deb-bundle# 

安装包 安装过程中yum会自动解决依赖关系 并安装所需要的依赖包

yum install /root/package/mysql/mysql-5.7.35-1.el7.x86_64.rpm-bundle/mysql-community-{server,client,common,libs}-* mysql-5.*
[root@centos ~]# yum install /root/package/mysql/mysql-5.7.35-1.el7.x86_64.rpm-bundle/mysql-community-{server,client,common,libs}-* mysql-5.*
Loaded plugins: fastestmirror
Examining /root/package/mysql/mysql-5.7.35-1.el7.x86_64.rpm-bundle/mysql-community-server-5.7.35-1.el7.x86_64.rpm: mysql-community-server-5.7.35-1.el7.x86_64
Marking /root/package/mysql/mysql-5.7.35-1.el7.x86_64.rpm-bundle/mysql-community-server-5.7.35-1.el7.x86_64.rpm to be installed
Examining /root/package/mysql/mysql-5.7.35-1.el7.x86_64.rpm-bundle/mysql-community-client-5.7.35-1.el7.x86_64.rpm: mysql-community-client-5.7.35-1.el7.x86_64
Marking /root/package/mysql/mysql-5.7.35-1.el7.x86_64.rpm-bundle/mysql-community-client-5.7.35-1.el7.x86_64.rpm to be installed
Examining /root/package/mysql/mysql-5.7.35-1.el7.x86_64.rpm-bundle/mysql-community-common-5.7.35-1.el7.x86_64.rpm: mysql-community-common-5.7.35-1.el7.x86_64
Marking /root/package/mysql/mysql-5.7.35-1.el7.x86_64.rpm-bundle/mysql-community-common-5.7.35-1.el7.x86_64.rpm to be installed
Examining /root/package/mysql/mysql-5.7.35-1.el7.x86_64.rpm-bundle/mysql-community-libs-5.7.35-1.el7.x86_64.rpm: mysql-community-libs-5.7.35-1.el7.x86_64
Marking /root/package/mysql/mysql-5.7.35-1.el7.x86_64.rpm-bundle/mysql-community-libs-5.7.35-1.el7.x86_64.rpm to be installed
Examining /root/package/mysql/mysql-5.7.35-1.el7.x86_64.rpm-bundle/mysql-community-libs-compat-5.7.35-1.el7.x86_64.rpm: mysql-community-libs-compat-5.7.35-1.el7.x86_64
Marking /root/package/mysql/mysql-5.7.35-1.el7.x86_64.rpm-bundle/mysql-community-libs-compat-5.7.35-1.el7.x86_64.rpm to be installed
Loading mirror speeds from cached hostfile
No package mysql-5.* available.
Resolving Dependencies
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.60-1.el7_5 will be obsoleted
---> Package mysql-community-client.x86_64 0:5.7.35-1.el7 will be installed
---> Package mysql-community-common.x86_64 0:5.7.35-1.el7 will be installed
---> Package mysql-community-libs.x86_64 0:5.7.35-1.el7 will be obsoleting
---> Package mysql-community-libs-compat.x86_64 0:5.7.35-1.el7 will be obsoleting
---> Package mysql-community-server.x86_64 0:5.7.35-1.el7 will be installed
--> Processing Dependency: /usr/bin/perl for package: mysql-community-server-5.7.35-1.el7.x86_64
--> Processing Dependency: net-tools for package: mysql-community-server-5.7.35-1.el7.x86_64
--> Processing Dependency: perl(Getopt::Long) for package: mysql-community-server-5.7.35-1.el7.x86_64
--> Processing Dependency: perl(strict) for package: mysql-community-server-5.7.35-1.el7.x86_64
--> Running transaction check
---> Package net-tools.x86_64 0:2.0-0.25.20131004git.el7 will be installed
---> Package perl.x86_64 4:5.16.3-299.el7_9 will be installed
--> Processing Dependency: perl-libs = 4:5.16.3-299.el7_9 for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(Socket) >= 1.3 for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(Scalar::Util) >= 1.10 for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl-macros for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl-libs for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(threads::shared) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(threads) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(constant) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(Time::Local) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(Time::HiRes) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(Storable) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(Socket) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(Scalar::Util) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(Pod::Simple::XHTML) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(Pod::Simple::Search) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(Filter::Util::Call) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(File::Temp) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(File::Spec::Unix) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(File::Spec::Functions) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(File::Spec) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(File::Path) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(Exporter) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(Cwd) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(Carp) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: libperl.so()(64bit) for package: 4:perl-5.16.3-299.el7_9.x86_64
---> Package perl-Getopt-Long.noarch 0:2.40-3.el7 will be installed
--> Processing Dependency: perl(Pod::Usage) >= 1.14 for package: perl-Getopt-Long-2.40-3.el7.noarch
--> Processing Dependency: perl(Text::ParseWords) for package: perl-Getopt-Long-2.40-3.el7.noarch
--> Running transaction check
---> Package perl-Carp.noarch 0:1.26-244.el7 will be installed
---> Package perl-Exporter.noarch 0:5.68-3.el7 will be installed
---> Package perl-File-Path.noarch 0:2.09-2.el7 will be installed
---> Package perl-File-Temp.noarch 0:0.23.01-3.el7 will be installed
---> Package perl-Filter.x86_64 0:1.49-3.el7 will be installed
---> Package perl-PathTools.x86_64 0:3.40-5.el7 will be installed
---> Package perl-Pod-Simple.noarch 1:3.28-4.el7 will be installed
--> Processing Dependency: perl(Pod::Escapes) >= 1.04 for package: 1:perl-Pod-Simple-3.28-4.el7.noarch
--> Processing Dependency: perl(Encode) for package: 1:perl-Pod-Simple-3.28-4.el7.noarch
---> Package perl-Pod-Usage.noarch 0:1.63-3.el7 will be installed
--> Processing Dependency: perl(Pod::Text) >= 3.15 for package: perl-Pod-Usage-1.63-3.el7.noarch
--> Processing Dependency: perl-Pod-Perldoc for package: perl-Pod-Usage-1.63-3.el7.noarch
---> Package perl-Scalar-List-Utils.x86_64 0:1.27-248.el7 will be installed
---> Package perl-Socket.x86_64 0:2.010-5.el7 will be installed
---> Package perl-Storable.x86_64 0:2.45-3.el7 will be installed
---> Package perl-Text-ParseWords.noarch 0:3.29-4.el7 will be installed
---> Package perl-Time-HiRes.x86_64 4:1.9725-3.el7 will be installed
---> Package perl-Time-Local.noarch 0:1.2300-2.el7 will be installed
---> Package perl-constant.noarch 0:1.27-2.el7 will be installed
---> Package perl-libs.x86_64 4:5.16.3-299.el7_9 will be installed
---> Package perl-macros.x86_64 4:5.16.3-299.el7_9 will be installed
---> Package perl-threads.x86_64 0:1.87-4.el7 will be installed
---> Package perl-threads-shared.x86_64 0:1.43-6.el7 will be installed
--> Running transaction check
---> Package perl-Encode.x86_64 0:2.51-7.el7 will be installed
---> Package perl-Pod-Escapes.noarch 1:1.04-299.el7_9 will be installed
---> Package perl-Pod-Perldoc.noarch 0:3.20-4.el7 will be installed
--> Processing Dependency: perl(parent) for package: perl-Pod-Perldoc-3.20-4.el7.noarch
--> Processing Dependency: perl(HTTP::Tiny) for package: perl-Pod-Perldoc-3.20-4.el7.noarch
---> Package perl-podlators.noarch 0:2.5.1-3.el7 will be installed
--> Running transaction check
---> Package perl-HTTP-Tiny.noarch 0:0.033-3.el7 will be installed
---> Package perl-parent.noarch 1:0.225-244.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================================================================================================================================
 Package                                            Arch                          Version                                          Repository                                                               Size
=================================================================================================================================================================================================================
Installing:
 mysql-community-client                             x86_64                        5.7.35-1.el7                                     /mysql-community-client-5.7.35-1.el7.x86_64                             102 M
 mysql-community-common                             x86_64                        5.7.35-1.el7                                     /mysql-community-common-5.7.35-1.el7.x86_64                             2.8 M
 mysql-community-libs                               x86_64                        5.7.35-1.el7                                     /mysql-community-libs-5.7.35-1.el7.x86_64                               9.5 M
     replacing  mariadb-libs.x86_64 1:5.5.60-1.el7_5
 mysql-community-libs-compat                        x86_64                        5.7.35-1.el7                                     /mysql-community-libs-compat-5.7.35-1.el7.x86_64                        6.0 M
     replacing  mariadb-libs.x86_64 1:5.5.60-1.el7_5
 mysql-community-server                             x86_64                        5.7.35-1.el7                                     /mysql-community-server-5.7.35-1.el7.x86_64                             763 M
Installing for dependencies:
 net-tools                                          x86_64                        2.0-0.25.20131004git.el7                         base                                                                    306 k
 perl                                               x86_64                        4:5.16.3-299.el7_9                               updates                                                                 8.0 M
 perl-Carp                                          noarch                        1.26-244.el7                                     base                                                                     19 k
 perl-Encode                                        x86_64                        2.51-7.el7                                       base                                                                    1.5 M
 perl-Exporter                                      noarch                        5.68-3.el7                                       base                                                                     28 k
 perl-File-Path                                     noarch                        2.09-2.el7                                       base                                                                     26 k
 perl-File-Temp                                     noarch                        0.23.01-3.el7                                    base                                                                     56 k
 perl-Filter                                        x86_64                        1.49-3.el7                                       base                                                                     76 k
 perl-Getopt-Long                                   noarch                        2.40-3.el7                                       base                                                                     56 k
 perl-HTTP-Tiny                                     noarch                        0.033-3.el7                                      base                                                                     38 k
 perl-PathTools                                     x86_64                        3.40-5.el7                                       base                                                                     82 k
 perl-Pod-Escapes                                   noarch                        1:1.04-299.el7_9                                 updates                                                                  52 k
 perl-Pod-Perldoc                                   noarch                        3.20-4.el7                                       base                                                                     87 k
 perl-Pod-Simple                                    noarch                        1:3.28-4.el7                                     base                                                                    216 k
 perl-Pod-Usage                                     noarch                        1.63-3.el7                                       base                                                                     27 k
 perl-Scalar-List-Utils                             x86_64                        1.27-248.el7                                     base                                                                     36 k
 perl-Socket                                        x86_64                        2.010-5.el7                                      base                                                                     49 k
 perl-Storable                                      x86_64                        2.45-3.el7                                       base                                                                     77 k
 perl-Text-ParseWords                               noarch                        3.29-4.el7                                       base                                                                     14 k
 perl-Time-HiRes                                    x86_64                        4:1.9725-3.el7                                   base                                                                     45 k
 perl-Time-Local                                    noarch                        1.2300-2.el7                                     base                                                                     24 k
 perl-constant                                      noarch                        1.27-2.el7                                       base                                                                     19 k
 perl-libs                                          x86_64                        4:5.16.3-299.el7_9                               updates                                                                 690 k
 perl-macros                                        x86_64                        4:5.16.3-299.el7_9                               updates                                                                  44 k
 perl-parent                                        noarch                        1:0.225-244.el7                                  base                                                                     12 k
 perl-podlators                                     noarch                        2.5.1-3.el7                                      base                                                                    112 k
 perl-threads                                       x86_64                        1.87-4.el7                                       base                                                                     49 k
 perl-threads-shared                                x86_64                        1.43-6.el7                                       base                                                                     39 k

Transaction Summary
=================================================================================================================================================================================================================
Install  5 Packages (+28 Dependent packages)

Total size: 895 M
Total download size: 12 M
Is this ok [y/d/N]: y
Downloading packages:
(1/28): net-tools-2.0-0.25.20131004git.el7.x86_64.rpm                                                                                                                                     | 306 kB  00:00:00     
(2/28): perl-Carp-1.26-244.el7.noarch.rpm                                                                                                                                                 |  19 kB  00:00:00     
(3/28): perl-Exporter-5.68-3.el7.noarch.rpm                                                                                                                                               |  28 kB  00:00:00     
(4/28): perl-File-Path-2.09-2.el7.noarch.rpm                                                                                                                                              |  26 kB  00:00:00     
(5/28): perl-File-Temp-0.23.01-3.el7.noarch.rpm                                                                                                                                           |  56 kB  00:00:00     
(6/28): perl-Filter-1.49-3.el7.x86_64.rpm                                                                                                                                                 |  76 kB  00:00:00     
(7/28): perl-Getopt-Long-2.40-3.el7.noarch.rpm                                                                                                                                            |  56 kB  00:00:00     
(8/28): perl-Encode-2.51-7.el7.x86_64.rpm                                                                                                                                                 | 1.5 MB  00:00:00     
(9/28): perl-HTTP-Tiny-0.033-3.el7.noarch.rpm                                                                                                                                             |  38 kB  00:00:00     
(10/28): perl-PathTools-3.40-5.el7.x86_64.rpm                                                                                                                                             |  82 kB  00:00:00     
(11/28): perl-Pod-Perldoc-3.20-4.el7.noarch.rpm                                                                                                                                           |  87 kB  00:00:00     
(12/28): perl-Pod-Usage-1.63-3.el7.noarch.rpm                                                                                                                                             |  27 kB  00:00:00     
(13/28): perl-Scalar-List-Utils-1.27-248.el7.x86_64.rpm                                                                                                                                   |  36 kB  00:00:00     
(14/28): perl-Socket-2.010-5.el7.x86_64.rpm                                                                                                                                               |  49 kB  00:00:00     
(15/28): perl-Storable-2.45-3.el7.x86_64.rpm                                                                                                                                              |  77 kB  00:00:00     
(16/28): perl-Text-ParseWords-3.29-4.el7.noarch.rpm                                                                                                                                       |  14 kB  00:00:00     
(17/28): perl-Time-HiRes-1.9725-3.el7.x86_64.rpm                                                                                                                                          |  45 kB  00:00:00     
(18/28): perl-Time-Local-1.2300-2.el7.noarch.rpm                                                                                                                                          |  24 kB  00:00:00     
(19/28): perl-constant-1.27-2.el7.noarch.rpm                                                                                                                                              |  19 kB  00:00:00     
(20/28): perl-Pod-Escapes-1.04-299.el7_9.noarch.rpm                                                                                                                                       |  52 kB  00:00:00     
(21/28): perl-Pod-Simple-3.28-4.el7.noarch.rpm                                                                                                                                            | 216 kB  00:00:00     
(22/28): perl-libs-5.16.3-299.el7_9.x86_64.rpm                                                                                                                                            | 690 kB  00:00:00     
(23/28): perl-macros-5.16.3-299.el7_9.x86_64.rpm                                                                                                                                          |  44 kB  00:00:00     
(24/28): perl-5.16.3-299.el7_9.x86_64.rpm                                                                                                                                                 | 8.0 MB  00:00:01     
(25/28): perl-parent-0.225-244.el7.noarch.rpm                                                                                                                                             |  12 kB  00:00:00     
(26/28): perl-threads-1.87-4.el7.x86_64.rpm                                                                                                                                               |  49 kB  00:00:00     
(27/28): perl-threads-shared-1.43-6.el7.x86_64.rpm                                                                                                                                        |  39 kB  00:00:00     
(28/28): perl-podlators-2.5.1-3.el7.noarch.rpm                                                                                                                                            | 112 kB  00:00:00     
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                            6.4 MB/s |  12 MB  00:00:01     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : mysql-community-common-5.7.35-1.el7.x86_64                                                                                                                                                   1/34 
  Installing : mysql-community-libs-5.7.35-1.el7.x86_64                                                                                                                                                     2/34 
  Installing : mysql-community-client-5.7.35-1.el7.x86_64                                                                                                                                                   3/34 
  Installing : 1:perl-parent-0.225-244.el7.noarch                                                                                                                                                           4/34 
  Installing : perl-HTTP-Tiny-0.033-3.el7.noarch                                                                                                                                                            5/34 
  Installing : perl-podlators-2.5.1-3.el7.noarch                                                                                                                                                            6/34 
  Installing : perl-Pod-Perldoc-3.20-4.el7.noarch                                                                                                                                                           7/34 
  Installing : 1:perl-Pod-Escapes-1.04-299.el7_9.noarch                                                                                                                                                     8/34 
  Installing : perl-Encode-2.51-7.el7.x86_64                                                                                                                                                                9/34 
  Installing : perl-Text-ParseWords-3.29-4.el7.noarch                                                                                                                                                      10/34 
  Installing : perl-Pod-Usage-1.63-3.el7.noarch                                                                                                                                                            11/34 
  Installing : 4:perl-macros-5.16.3-299.el7_9.x86_64                                                                                                                                                       12/34 
  Installing : perl-Storable-2.45-3.el7.x86_64                                                                                                                                                             13/34 
  Installing : perl-Exporter-5.68-3.el7.noarch                                                                                                                                                             14/34 
  Installing : perl-constant-1.27-2.el7.noarch                                                                                                                                                             15/34 
  Installing : perl-Socket-2.010-5.el7.x86_64                                                                                                                                                              16/34 
  Installing : perl-Time-Local-1.2300-2.el7.noarch                                                                                                                                                         17/34 
  Installing : perl-Carp-1.26-244.el7.noarch                                                                                                                                                               18/34 
  Installing : 4:perl-Time-HiRes-1.9725-3.el7.x86_64                                                                                                                                                       19/34 
  Installing : perl-PathTools-3.40-5.el7.x86_64                                                                                                                                                            20/34 
  Installing : perl-Scalar-List-Utils-1.27-248.el7.x86_64                                                                                                                                                  21/34 
  Installing : 1:perl-Pod-Simple-3.28-4.el7.noarch                                                                                                                                                         22/34 
  Installing : perl-File-Temp-0.23.01-3.el7.noarch                                                                                                                                                         23/34 
  Installing : perl-File-Path-2.09-2.el7.noarch                                                                                                                                                            24/34 
  Installing : perl-threads-shared-1.43-6.el7.x86_64                                                                                                                                                       25/34 
  Installing : perl-threads-1.87-4.el7.x86_64                                                                                                                                                              26/34 
  Installing : perl-Filter-1.49-3.el7.x86_64                                                                                                                                                               27/34 
  Installing : 4:perl-libs-5.16.3-299.el7_9.x86_64                                                                                                                                                         28/34 
  Installing : perl-Getopt-Long-2.40-3.el7.noarch                                                                                                                                                          29/34 
  Installing : 4:perl-5.16.3-299.el7_9.x86_64                                                                                                                                                              30/34 
  Installing : net-tools-2.0-0.25.20131004git.el7.x86_64                                                                                                                                                   31/34 
  Installing : mysql-community-server-5.7.35-1.el7.x86_64                                                                                                                                                  32/34 
  Installing : mysql-community-libs-compat-5.7.35-1.el7.x86_64                                                                                                                                             33/34 
  Erasing    : 1:mariadb-libs-5.5.60-1.el7_5.x86_64                                                                                                                                                        34/34 
  Verifying  : mysql-community-server-5.7.35-1.el7.x86_64                                                                                                                                                   1/34 
  Verifying  : perl-HTTP-Tiny-0.033-3.el7.noarch                                                                                                                                                            2/34 
  Verifying  : perl-threads-shared-1.43-6.el7.x86_64                                                                                                                                                        3/34 
  Verifying  : perl-Storable-2.45-3.el7.x86_64                                                                                                                                                              4/34 
  Verifying  : perl-Exporter-5.68-3.el7.noarch                                                                                                                                                              5/34 
  Verifying  : perl-constant-1.27-2.el7.noarch                                                                                                                                                              6/34 
  Verifying  : perl-PathTools-3.40-5.el7.x86_64                                                                                                                                                             7/34 
  Verifying  : perl-Socket-2.010-5.el7.x86_64                                                                                                                                                               8/34 
  Verifying  : 1:perl-parent-0.225-244.el7.noarch                                                                                                                                                           9/34 
  Verifying  : 4:perl-macros-5.16.3-299.el7_9.x86_64                                                                                                                                                       10/34 
  Verifying  : mysql-community-client-5.7.35-1.el7.x86_64                                                                                                                                                  11/34 
  Verifying  : mysql-community-libs-5.7.35-1.el7.x86_64                                                                                                                                                    12/34 
  Verifying  : perl-File-Temp-0.23.01-3.el7.noarch                                                                                                                                                         13/34 
  Verifying  : net-tools-2.0-0.25.20131004git.el7.x86_64                                                                                                                                                   14/34 
  Verifying  : 1:perl-Pod-Simple-3.28-4.el7.noarch                                                                                                                                                         15/34 
  Verifying  : perl-Time-Local-1.2300-2.el7.noarch                                                                                                                                                         16/34 
  Verifying  : 1:perl-Pod-Escapes-1.04-299.el7_9.noarch                                                                                                                                                    17/34 
  Verifying  : perl-Carp-1.26-244.el7.noarch                                                                                                                                                               18/34 
  Verifying  : 4:perl-Time-HiRes-1.9725-3.el7.x86_64                                                                                                                                                       19/34 
  Verifying  : perl-Scalar-List-Utils-1.27-248.el7.x86_64                                                                                                                                                  20/34 
  Verifying  : mysql-community-libs-compat-5.7.35-1.el7.x86_64                                                                                                                                             21/34 
  Verifying  : perl-Pod-Usage-1.63-3.el7.noarch                                                                                                                                                            22/34 
  Verifying  : perl-Encode-2.51-7.el7.x86_64                                                                                                                                                               23/34 
  Verifying  : perl-Pod-Perldoc-3.20-4.el7.noarch                                                                                                                                                          24/34 
  Verifying  : perl-podlators-2.5.1-3.el7.noarch                                                                                                                                                           25/34 
  Verifying  : 4:perl-5.16.3-299.el7_9.x86_64                                                                                                                                                              26/34 
  Verifying  : perl-File-Path-2.09-2.el7.noarch                                                                                                                                                            27/34 
  Verifying  : perl-threads-1.87-4.el7.x86_64                                                                                                                                                              28/34 
  Verifying  : mysql-community-common-5.7.35-1.el7.x86_64                                                                                                                                                  29/34 
  Verifying  : perl-Filter-1.49-3.el7.x86_64                                                                                                                                                               30/34 
  Verifying  : perl-Getopt-Long-2.40-3.el7.noarch                                                                                                                                                          31/34 
  Verifying  : perl-Text-ParseWords-3.29-4.el7.noarch                                                                                                                                                      32/34 
  Verifying  : 4:perl-libs-5.16.3-299.el7_9.x86_64                                                                                                                                                         33/34 
  Verifying  : 1:mariadb-libs-5.5.60-1.el7_5.x86_64                                                                                                                                                        34/34 

Installed:
  mysql-community-client.x86_64 0:5.7.35-1.el7       mysql-community-common.x86_64 0:5.7.35-1.el7       mysql-community-libs.x86_64 0:5.7.35-1.el7       mysql-community-libs-compat.x86_64 0:5.7.35-1.el7      
  mysql-community-server.x86_64 0:5.7.35-1.el7      

Dependency Installed:
  net-tools.x86_64 0:2.0-0.25.20131004git.el7  perl.x86_64 4:5.16.3-299.el7_9           perl-Carp.noarch 0:1.26-244.el7         perl-Encode.x86_64 0:2.51-7.el7          perl-Exporter.noarch 0:5.68-3.el7    
  perl-File-Path.noarch 0:2.09-2.el7           perl-File-Temp.noarch 0:0.23.01-3.el7    perl-Filter.x86_64 0:1.49-3.el7         perl-Getopt-Long.noarch 0:2.40-3.el7     perl-HTTP-Tiny.noarch 0:0.033-3.el7  
  perl-PathTools.x86_64 0:3.40-5.el7           perl-Pod-Escapes.noarch 1:1.04-299.el7_9 perl-Pod-Perldoc.noarch 0:3.20-4.el7    perl-Pod-Simple.noarch 1:3.28-4.el7      perl-Pod-Usage.noarch 0:1.63-3.el7   
  perl-Scalar-List-Utils.x86_64 0:1.27-248.el7 perl-Socket.x86_64 0:2.010-5.el7         perl-Storable.x86_64 0:2.45-3.el7       perl-Text-ParseWords.noarch 0:3.29-4.el7 perl-Time-HiRes.x86_64 4:1.9725-3.el7
  perl-Time-Local.noarch 0:1.2300-2.el7        perl-constant.noarch 0:1.27-2.el7        perl-libs.x86_64 4:5.16.3-299.el7_9     perl-macros.x86_64 4:5.16.3-299.el7_9    perl-parent.noarch 1:0.225-244.el7   
  perl-podlators.noarch 0:2.5.1-3.el7          perl-threads.x86_64 0:1.87-4.el7         perl-threads-shared.x86_64 0:1.43-6.el7

Replaced:
  mariadb-libs.x86_64 1:5.5.60-1.el7_5                                                                                                                                                                           

Complete!
[root@centos ~]# 

此次安装是mysql数据库标准安装方式,只安装了这些包。没有安装开发包等其他包。

[root@centos ~]# ls -lh  /root/package/mysql/mysql-5.7.35-1.el7.x86_64.rpm-bundle/mysql-community-{server,client,common,libs}-* 
-rw-r--r--. 1 7155 31415  26M Jun  8  2021 /root/package/mysql/mysql-5.7.35-1.el7.x86_64.rpm-bundle/mysql-community-client-5.7.35-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 311K Jun  8  2021 /root/package/mysql/mysql-5.7.35-1.el7.x86_64.rpm-bundle/mysql-community-common-5.7.35-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 2.4M Jun  8  2021 /root/package/mysql/mysql-5.7.35-1.el7.x86_64.rpm-bundle/mysql-community-libs-5.7.35-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 1.3M Jun  8  2021 /root/package/mysql/mysql-5.7.35-1.el7.x86_64.rpm-bundle/mysql-community-libs-compat-5.7.35-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 174M Jun  8  2021 /root/package/mysql/mysql-5.7.35-1.el7.x86_64.rpm-bundle/mysql-community-server-5.7.35-1.el7.x86_64.rpm
[root@centos ~]# 

安装后会自动创建systemd服务
查看MySQL服务

systemctl status mysqld.service 
[root@centos ~]# systemctl status mysqld.service 
● 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@centos ~]# 

至此安装成功

安装后不会自动启动MySQL服务,手动开启服务

systemctl start mysqld.service

查看服务状态

systemctl status mysqld.service
[root@centos ~]# systemctl status mysqld.service 
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2023-05-15 03:05:58 EDT; 23s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 18326 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
  Process: 18276 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 18329 (mysqld)
   CGroup: /system.slice/mysqld.service
           └─18329 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid

May 15 03:05:48 centos systemd[1]: Starting MySQL Server...
May 15 03:05:58 centos systemd[1]: Started MySQL Server.
[root@centos ~]# 

在MySQL服务初次启动的过程中,做了以下操作:

  • The server is initialized
[root@centos ~]# systemctl status mysqld.service 
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2023-05-15 03:05:58 EDT; 23s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 18326 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
  Process: 18276 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 18329 (mysqld)
   CGroup: /system.slice/mysqld.service
           └─18329 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid

May 15 03:05:48 centos systemd[1]: Starting MySQL Server...
May 15 03:05:58 centos systemd[1]: Started MySQL Server.
[root@centos ~]# 
  • An SSL certificate and key files are generated in the data directory.

centos 7.6 安装mysql 5.7.35_第2张图片

  • validate_password is installed and enabled.
Note
validate_password is installed by default. The default password policy implemented 
by validate_password requires that passwords contain at least one uppercase letter,
one lowercase letter, one digit, and one special character, and that the total 
password length is at least 8 characters.
  • A superuser account ‘root’@‘localhost’ is created. A password for the superuser is set and stored in the error log file.
    查看自动生成的MySQL root 用户密码
grep 'temporary password' /var/log/mysqld.log

在这里插入图片描述

4、安装后形成的配置文件和程序位置

Files or Resources Location
Client programs and scripts /usr/bin
mysqld server /usr/sbin
Configuration file /etc/my.cnf
Data directory /var/lib/mysql
Error log file For RHEL, Oracle Linux, CentOS or Fedora platforms: /var/log/mysqld.log
Value of secure_file_priv /var/lib/mysql-files
System V init script For RHEL, Oracle Linux, CentOS or Fedora platforms: /etc/init.d/mysqld
Systemd service For RHEL, Oracle Linux, CentOS or Fedora platforms: mysqld
Pid file /var/run/mysql/mysqld.pid
Socket /var/lib/mysql/mysql.sock
Keyring directory /var/lib/mysql-keyring
Unix manual pages /usr/share/man
Include (header) files /usr/include/mysql
Libraries /usr/lib/mysql
Miscellaneous support files (for example, error messages, and character set files) /usr/share/mysql

5、安装后设置

5.1、修改MySQL root账户默认密码

执行以下SQL语句修改密码复杂度校验校验规则为只包含数字、校验长度为1、设置root密码为123456、赋予root用户远程连接权限。

SET GLOBAL validate_password_policy = 0;


SET GLOBAL validate_password_length = 1;


SET PASSWORD = PASSWORD ("123456");

commit;

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

commit;

不修改无法执行数据库命令
centos 7.6 安装mysql 5.7.35_第3张图片

centos 7.6 安装mysql 5.7.35_第4张图片

密码校验长度设置是1,实际设置的是4。设置为1是不允许的。

在这里插入图片描述

5.2、关闭系统防火墙

systemctl stop firewalld.service

不关闭防火墙的话 MySQL连接不上

6、使用mysql 5.7.35 数据库

6.1、命令行登录MySQL 5.7.35 数据库

登录数据库root账户 密码是安装MySQL时设置的root账户密码

mysql -uroot -p

使用安装后自动生成的MySQL root 用户密码登录

[root@centos ~]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.35

Copyright (c) 2000, 2021, 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> 

查看默认所有数据库

show databases;
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql> 

创建数据库

create database test;
mysql> create database test;
Query OK, 1 row affected (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| test               |
+--------------------+
5 rows in set (0.00 sec)

mysql> 

6.2、navicat连接mysql 5.7.35 数据库

新建连接 选择mysql

centos 7.6 安装mysql 5.7.35_第5张图片

点击确定

centos 7.6 安装mysql 5.7.35_第6张图片

centos 7.6 安装mysql 5.7.35_第7张图片

centos 7.6 安装mysql 5.7.35_第8张图片

新建查询

centos 7.6 安装mysql 5.7.35_第9张图片

centos 7.6 安装mysql 5.7.35_第10张图片

centos 7.6 安装mysql 5.7.35_第11张图片

6.3、mysql数据库常用命令<5.7.35版本>

6.3.1、初始化默认数据库

初始化默认数据库

mysqld --initialize --console

在这里插入图片描述
在这里插入图片描述

mysqld命令帮助查看:

mysqld --verbose --help|less

centos 7.6 安装mysql 5.7.35_第12张图片

你可能感兴趣的:(linux,数据库,mysql,centos)