Linux下安装MySQL的两种方法

19 篇文章 0 订阅
4 篇文章 0 订阅

方法一:通过互联网yum源安装
去官方下载mysql的yum资源包:https://dev.mysql.com/downloads/repo/yum/

wget https://dev.mysql.com/get/mysql80-community-release-el7-2.noarch.rpm
rpm -ivh mysql80-community-release-el7-2.noarch.rpm
yum update
yum install mysql-server
systemctl start mysqld
systemctl enabled mysqld
systcmctl status mysqld

方法二:把msyql的安装包下载到本地安装:

wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.15-1.el7.x86_64.rpm-bundle.tar
tar -xvf mysql-8.0.15-1.el7.x86_64.rpm-bundle.tar
ls -l
[root@localhost mysql]# ll
total 508956
-rw-r--r-- 1 7155 31415  26720140 Jan 27 07:58 mysql-community-client-8.0.15-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415    579496 Jan 27 07:58 mysql-community-common-8.0.15-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415   4069708 Jan 27 07:58 mysql-community-devel-8.0.15-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415  24348864 Jan 27 07:58 mysql-community-embedded-compat-8.0.15-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415   2316532 Jan 27 07:58 mysql-community-libs-8.0.15-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415   2161212 Jan 27 07:58 mysql-community-libs-compat-8.0.15-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 377842180 Jan 27 07:59 mysql-community-server-8.0.15-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415  83116136 Jan 27 07:59 mysql-community-test-8.0.15-1.el7.x86_64.rpm

开始进行安装rpm包:

rpm -ivh mysql-community-common-8.0.15-1.el7.x86_64.rpm
rpm -ivh  mysql-community-libs-compat-8.0.15-1.el7.x86_64.rpm
//安装这个包遇到一个报错
warning: mysql-community-libs-compat-8.0.15-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
        mysql-community-libs(x86-64) >= 8.0.0 is needed by mysql-community-libs-compat-8.0.15-1.el7.x86_64
        mariadb-libs is obsoleted by mysql-community-libs-compat-8.0.15-1.el7.x86_64

提示mariadb已经被lbsoleted废除了。所以先卸载这个mariadb rpm包

rpm -qa mariadb-libs
rpm -e mariadb-libs-5.5.56-2.el7.x86_64
//又出现一个报错
error: Failed dependencies:
        libmysqlclient.so.18()(64bit) is needed by (installed) postfix-2:2.10.1-6.el7.x86_64
        libmysqlclient.so.18(libmysqlclient_18)(64bit) is needed by (installed) postfix-2:2.10.1-6.el7.x86_64
//继续卸载
rpm -e postfix-2:2.10.1-6.el7.x86_64
rpm -e mariadb-libs-5.5.56-2.el7.x86_64
//继续安装
mysql-community-libs-8.0.15-1.el7.x86_64.rpm
mysql-community-client-8.0.15-1.el7.x86_64.rpm
mysql-community-server-8.0.15-1.el7.x86_64.rpm
启动mysqld:
systemctl start mysqld
systemctl enable mysqld

3、其他tips:
想查询mysql的配置文件或者日志文件,但是找不到怎么办。

man mysqld

看到有如下提示:

       The mysqld program has many options that can be specified at startup. For a complete list of options, run this command:

           shell> mysqld --verbose --help

执行以上命令:

mysqld --verbose --help|more

可以看到:

[root@test02sz data]# mysqld --verbose --help|more
mysqld  Ver 8.0.15 for Linux on x86_64 (MySQL Community Server - GPL)
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

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

Starts the MySQL database server.

Usage: mysqld [OPTIONS]

Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf 

通过以上的cnf文件,可以查看到mysql相关的文件存放位置,比如第一次登陆mysql的时候需要去mysqld.log去查看初始密码。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值