CentOS7 Mysql安装部署

二、MySQL 安装部署

2.1 RPM包安装

2.1.1 yum在线安装

MySQL官方网站

1、下载并安装MySQL官方的 Yum Repository

[root@node1 ~]# wget -c https://dev.mysql.com/get/mysql80-community-release-el7-5.noarch.rpm

2、添加 MySQL Yum Repository

[root@node1 ~]# yum localinstall mysql80-community-release-el7-5.noarch.rpm -y

3、选择安装发行版

前提: 安装yum-utils包

[root@node1 ~]# yum-config-manager --disable mysql80-community   #禁用8.0
[root@node1 ~]# yum-config-manager --enable mysql57-community	#启用5.7

验证

[root@node1 ~]# yum repolist enabled | grep -i ^mysql
mysql-connectors-community/x86_64       MySQL Connectors Community           230
mysql-tools-community/x86_64            MySQL Tools Community                138
mysql57-community/x86_64                MySQL 5.7 Community Server           564

4、在线安装

[root@node1 ~]# yum install -y mysql-community-server

5、启动数据库

[root@node1 ~]# systemctl enable --now mysqld

6、登陆

[root@node1 ~]# tmp_pwd=`awk '/temporary password/ {print $NF}' /var/log/mysqld.log`
[root@node1 ~]# mysql -uroot -p$tmp_pwd
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 10
Server version: 5.7.37 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>

7、验证

#查看状态
[root@node1 ~]# systemctl status mysqld
#查看端口
[root@node1 ~]# netstat -lnpt | grep 3306
tcp6       0      0 :::3306                 :::*                    LISTEN      1823/mysqld
#查看进程
[root@node1 ~]# ps -ef | grep mysqld
mysql      1823      1  0 22:08 ?        00:00:00 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
root       1856   1393  0 22:10 pts/0    00:00:00 grep --color=auto mysqld

2.1.2 rpm包离线安装

事先从官网下载RPM安装包,上传至服务器:

[root@node2 ~]# ls -l mysql-5.7.37-1.el7.x86_64.rpm-bundle.tar
-rw-r--r-- 1 root root 545894400 Mar 27 22:31 mysql-5.7.37-1.el7.x86_64.rpm-bundle.tar

解压查看:

[root@node2 ~]# tar xf mysql-5.7.37-1.el7.x86_64.rpm-bundle.tar
[root@node2 ~]# ls -l mysql-community-*
-rw-r--r-- 1 7155 31415  26670472 Dec 16 10:01 mysql-community-client-5.7.37-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415    318884 Dec 16 10:01 mysql-community-common-5.7.37-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415   4122424 Dec 16 10:01 mysql-community-devel-5.7.37-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415  47760004 Dec 16 10:02 mysql-community-embedded-5.7.37-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415  23316972 Dec 16 10:02 mysql-community-embedded-compat-5.7.37-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 132204460 Dec 16 10:02 mysql-community-embedded-devel-5.7.37-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415   2474780 Dec 16 10:02 mysql-community-libs-5.7.37-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415   1264836 Dec 16 10:02 mysql-community-libs-compat-5.7.37-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 182274360 Dec 16 10:02 mysql-community-server-5.7.37-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值