centos快速安装mysql

一、在线快速安装
1、安装yum源
首先在mysql官网上找到对应centos版本的yum源,https://dev.mysql.com/downloads/repo/yum/。
在这里插入图片描述tips:centos8只能安装mysql8。

[root@compute-01 ~]# cat /etc/redhat-release     #本机是centos7的环境,所以需要下载对应的yum包;
CentOS Linux release 7.7.1908 (Core)
[root@compute-01 ~]# wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
[root@compute-01 ~]# rpm -ivh mysql80-community-release-el7-3.noarch.rpm   #安装yum源
warning: mysql80-community-release-el7-3.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql80-community-release-el7-3  ################################# [100%]
   
#可以手动修改使能mysql5.7或者mysql8
[root@compute-01 ~]# vim /etc/yum.repos.d/mysql-community.repo    

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

[mysql80-community]
name=MySQL 8.0 Community Server
baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/7/$basearch/
**enabled=0**
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

也可以使用yum修改
[root@compute-01 ~]#  yum-config-manager --enable mysql57-community
[root@compute-01 ~]#  yum-config-manager --disable mysql80-community

安装mysql
[root@compute-01 ~]# yum install mysql-server -y

二、使用rpm包离线安装mysql
在mysql官网https://dev.mysql.com/downloads/下载相应的rpm包。
在这里插入图片描述
选取想要安装的版本和系统环境,下载相应的包
在这里插入图片描述

三、启动mysql

[root@compute-01 ~]# 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@compute-01 ~]# systemctl start mysqld
[root@compute-01 ~]# systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2021-08-17 16:32:02 CST; 3s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 18410 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
  Process: 18354 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 18412 (mysqld)
    Tasks: 27
   Memory: 319.0M
   CGroup: /system.slice/mysqld.service
           └─18412 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid

Aug 17 16:31:55 compute-01 systemd[1]: Starting MySQL Server...
Aug 17 16:32:02 compute-01 systemd[1]: Started MySQL Server.

tips:mysql5的密码是通过自动生成保存在mysql日志里,文件路径是:/var/log/mysqld.log
[root@compute-01 ~]# cat /var/log/mysqld.log | grep pass
2021-08-17T08:31:59.273120Z 1 [Note] A temporary password is generated for root@localhost: 73*6SM*7zZd5

root@compute-01 ~]# mysql -uroot -p
Enter password:     #需要使用日志里的密码登录
mysql> alter user root@localhost identified by 'XXXXXXXX';  登录mysql后首先需求修改密码,密码强度需要符合相关策略;


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值