centos7安装mysql

安装

1.下载rpm包

[root@server soft]# wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
--2024-05-26 00:47:10--  http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
Resolving repo.mysql.com (repo.mysql.com)... 92.122.81.156, 2a02:26f0:61:183::1d68, 2a02:26f0:61:18d::1d68
Connecting to repo.mysql.com (repo.mysql.com)|92.122.81.156|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 6140 (6.0K) [application/x-redhat-package-manager]
Saving to: ‘mysql-community-release-el7-5.noarch.rpm’

100%[==================>] 6,140       --.-K/s   in 0s      

2024-05-26 00:47:10 (662 MB/s) - ‘mysql-community-release-el7-5.noarch.rpm’ saved [6140/6140]

[root@server soft]# ls
mysql-community-release-el7-5.noarch.rpm

2.安装MySQL

[root@server soft]# yum install  -y  mysql-community-release-el7-5.noarch.rpm
Loaded plugins: fastestmirror, langpacks
Examining mysql-community-release-el7-5.noarch.rpm: mysql-community-release-el7-5.noarch
Marking mysql-community-release-el7-5.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-release.noarch 0:el7-5 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

============================================================
 Package
   Arch   Version
                Repository                             Size
============================================================
Installing:
 mysql-community-release
   noarch el7-5 /mysql-community-release-el7-5.noarch 4.3 k

Transaction Summary
============================================================
Install  1 Package

Total size: 4.3 k
Installed size: 4.3 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : mysql-community-release-el7-5.noarch     1/1 
  Verifying  : mysql-community-release-el7-5.noarch     1/1 

Installed:
  mysql-community-release.noarch 0:el7-5                    

Complete!

3.安装MySQL服务端

[root@server soft]# yum install -y mysql-community-server
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
mysql-connectors-community           | 2.6 kB     00:00     
mysql-tools-community                | 2.6 kB     00:00     
mysql56-community                    | 2.6 kB     00:00     
(1/3): mysql-connectors-community/x86_ | 114 kB   00:01     
(2/3): mysql-tools-community/x86_64/pr |  98 kB   00:01     
(3/3): mysql56-community/x86_64/primar | 297 kB   00:01     
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.6.51-2.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.6.51-2.el7 for package: mysql-community-server-5.6.51-2.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 5.6.10 for package: mysql-community-server-5.6.51-2.el7.x86_64
--> Processing Dependency: perl(DBI) for package: mysql-community-server-5.6.51-2.el7.x86_64
--> Processing Dependency: perl(Data::Dumper) for package: mysql-community-server-5.6.51-2.el7.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.6.51-2.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.6.10 for package: mysql-community-client-5.6.51-2.el7.x86_64
---> Package mysql-community-common.x86_64 0:5.6.51-2.el7 will be installed
---> Package perl-DBI.x86_64 0:1.627-4.el7 will be installed
--> Processing Dependency: perl(RPC::PlServer) >= 0.2001 for package: perl-DBI-1.627-4.el7.x86_64
--> Processing Dependency: perl(RPC::PlClient) >= 0.2000 for package: perl-DBI-1.627-4.el7.x86_64
---> Package perl-Data-Dumper.x86_64 0:2.145-3.el7 will be installed
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.68-1.el7 will be obsoleted
---> Package mysql-community-libs.x86_64 0:5.6.51-2.el7 will be obsoleting
---> Package perl-PlRPC.noarch 0:0.2020-14.el7 will be installed
--> Processing Dependency: perl(Net::Daemon) >= 0.13 for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Net::Daemon::Test) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Net::Daemon::Log) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Compress::Zlib) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Running transaction check
---> Package perl-IO-Compress.noarch 0:2.061-2.el7 will be installed
--> Processing Dependency: perl(Compress::Raw::Zlib) >= 2.061 for package: perl-IO-Compress-2.061-2.el7.noarch
--> Processing Dependency: perl(Compress::Raw::Bzip2) >= 2.061 for package: perl-IO-Compress-2.061-2.el7.noarch
---> Package perl-Net-Daemon.noarch 0:0.48-5.el7 will be installed
--> Running transaction check
---> Package perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 will be installed
---> Package perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

============================================================
 Package                 Arch   Version       Repository
                                                       Size
============================================================
Installing:
 mysql-community-libs    x86_64 5.6.51-2.el7  mysql56-community
                                                      2.2 M
     replacing  mariadb-libs.x86_64 1:5.5.68-1.el7
 mysql-community-server  x86_64 5.6.51-2.el7  mysql56-community
                                                       67 M
Installing for dependencies:
 mysql-community-client  x86_64 5.6.51-2.el7  mysql56-community
                                                       21 M
 mysql-community-common  x86_64 5.6.51-2.el7  mysql56-community
                                                      287 k
 perl-Compress-Raw-Bzip2 x86_64 2.061-3.el7   base     32 k
 perl-Compress-Raw-Zlib  x86_64 1:2.061-4.el7 base     57 k
 perl-DBI                x86_64 1.627-4.el7   base    802 k
 perl-Data-Dumper        x86_64 2.145-3.el7   base     47 k
 perl-IO-Compress        noarch 2.061-2.el7   base    260 k
 perl-Net-Daemon         noarch 0.48-5.el7    base     51 k
 perl-PlRPC              noarch 0.2020-14.el7 base     36 k

Transaction Summary
============================================================
Install  2 Packages (+9 Dependent packages)

Total download size: 91 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/mysql56-community/packages/mysql-community-common-5.6.51-2.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Public key for mysql-community-common-5.6.51-2.el7.x86_64.rpm is not installed
(1/11): mysql-community-common-5.6.51- | 287 kB   00:01     
(2/11): mysql-community-libs-5.6.51-2. | 2.2 MB   00:01     
(3/11): perl-Compress-Raw-Zlib-2.061-4 |  57 kB   00:00     
(4/11): perl-Compress-Raw-Bzip2-2.061- |  32 kB   00:00     
(5/11): perl-Data-Dumper-2.145-3.el7.x |  47 kB   00:00     
(6/11): perl-DBI-1.627-4.el7.x86_64.rp | 802 kB   00:01     
(7/11): perl-Net-Daemon-0.48-5.el7.noa |  51 kB   00:00     
(8/11): perl-PlRPC-0.2020-14.el7.noarc |  36 kB   00:00     
(9/11): perl-IO-Compress-2.061-2.el7.n | 260 kB   00:01     
(10/11): mysql-community-server-5.6.51 |  67 MB   00:31     
(11/11): mysql-community-client-5.6.51 |  21 MB   00:47     
------------------------------------------------------------
Total                          1.9 MB/s |  91 MB  00:47     
Retrieving key from file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:
 Userid     : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
 Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
 Package    : mysql-community-release-el7-5.noarch (@/mysql-community-release-el7-5.noarch)
 From       : file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : mysql-community-common-5.6.51-2.el7.    1/12 
  Installing : perl-Data-Dumper-2.145-3.el7.x86_64     2/12 
  Installing : mysql-community-libs-5.6.51-2.el7.x8    3/12 
  Installing : mysql-community-client-5.6.51-2.el7.    4/12 
  Installing : perl-Compress-Raw-Bzip2-2.061-3.el7.    5/12 
  Installing : 1:perl-Compress-Raw-Zlib-2.061-4.el7    6/12 
  Installing : perl-IO-Compress-2.061-2.el7.noarch     7/12 
  Installing : perl-Net-Daemon-0.48-5.el7.noarch       8/12 
  Installing : perl-PlRPC-0.2020-14.el7.noarch         9/12 
  Installing : perl-DBI-1.627-4.el7.x86_64            10/12 
  Installing : mysql-community-server-5.6.51-2.el7.   11/12 
  Erasing    : 1:mariadb-libs-5.5.68-1.el7.x86_64     12/12 
  Verifying  : perl-Net-Daemon-0.48-5.el7.noarch       1/12 
  Verifying  : perl-Data-Dumper-2.145-3.el7.x86_64     2/12 
  Verifying  : mysql-community-libs-5.6.51-2.el7.x8    3/12 
  Verifying  : perl-IO-Compress-2.061-2.el7.noarch     4/12 
  Verifying  : mysql-community-server-5.6.51-2.el7.    5/12 
  Verifying  : 1:perl-Compress-Raw-Zlib-2.061-4.el7    6/12 
  Verifying  : mysql-community-common-5.6.51-2.el7.    7/12 
  Verifying  : perl-DBI-1.627-4.el7.x86_64             8/12 
  Verifying  : perl-Compress-Raw-Bzip2-2.061-3.el7.    9/12 
  Verifying  : perl-PlRPC-0.2020-14.el7.noarch        10/12 
  Verifying  : mysql-community-client-5.6.51-2.el7.   11/12 
  Verifying  : 1:mariadb-libs-5.5.68-1.el7.x86_64     12/12 

Installed:
  mysql-community-libs.x86_64 0:5.6.51-2.el7                
  mysql-community-server.x86_64 0:5.6.51-2.el7              

Dependency Installed:
  mysql-community-client.x86_64 0:5.6.51-2.el7              
  mysql-community-common.x86_64 0:5.6.51-2.el7              
  perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7              
  perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7               
  perl-DBI.x86_64 0:1.627-4.el7                             
  perl-Data-Dumper.x86_64 0:2.145-3.el7                     
  perl-IO-Compress.noarch 0:2.061-2.el7                     
  perl-Net-Daemon.noarch 0:0.48-5.el7                       
  perl-PlRPC.noarch 0:0.2020-14.el7                         

Replaced:
  mariadb-libs.x86_64 1:5.5.68-1.el7                        

Complete!

4.启动MySQL服务

[root@server soft]# systemctl start mysqld.service
[root@server soft]# systemctl status mysqld.service 
● mysqld.service - MySQL Community Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2024-05-26 00:50:36 PDT; 36s ago
  Process: 7276 ExecStartPost=/usr/bin/mysql-systemd-start post (code=exited, status=0/SUCCESS)
  Process: 7211 ExecStartPre=/usr/bin/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 7275 (mysqld_safe)
    Tasks: 23
   CGroup: /system.slice/mysqld.service
           ├─7275 /bin/sh /usr/bin/mysqld_safe --basedir=...
           └─7441 /usr/sbin/mysqld --basedir=/usr --datad...

May 26 00:50:33 server mysql-systemd-start[7211]: 2024-05...
May 26 00:50:33 server mysql-systemd-start[7211]: 2024-05...
May 26 00:50:33 server mysql-systemd-start[7211]: 2024-05...
May 26 00:50:35 server mysql-systemd-start[7211]: 2024-05...
May 26 00:50:35 server mysql-systemd-start[7211]: PLEASE ...
May 26 00:50:35 server mysql-systemd-start[7211]: To do s...
May 26 00:50:35 server mysql-systemd-start[7211]: /usr/bi...
May 26 00:50:35 server mysqld_safe[7275]: 240526 00:50:35...
May 26 00:50:35 server mysqld_safe[7275]: 240526 00:50:35...
May 26 00:50:36 server systemd[1]: Started MySQL Communit...
Hint: Some lines were ellipsized, use -l to show in full.

5.查看端口

[root@server soft]# netstat -na | grep 3306
tcp6       0      0 :::3306                 :::*                    LISTEN     

6.查看MySQL进程

[root@server soft]# ps -ef | grep mysql
mysql      7275      1  0 00:50 ?        00:00:00 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
mysql      7441   7275  0 00:50 ?        00:00:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock
root       7634   1540  0 00:59 pts/0    00:00:00 grep --color=auto mysql

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值