【Linux + Hadoop】使用rpm安装MySQL

11 篇文章 0 订阅

下载安装包

下载地址,选择适合自己的版本下载

可以选择整包下载,然后解压即可
在这里插入图片描述
可以去官网上下载,然后传到Linux,也可以直接使用命令下载

wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.22-1.el7.x86_64.rpm-bundle.tar

也可以单个下载
在这里插入图片描述
跳转顶部


卸载旧版本的MySQL

查看是否有旧版本的MySQL

rpm -qa | grep mysql

在这里插入图片描述
我这里显示没有,但是显示有的话,可以使用下列命令卸载

rpm -e --nodeps {-file-name}

安装

由于我下载的时整包,所以我需要先解压

tar -xvf mysql-5.7.22-1.el7.x86_64.rpm-bundle.tar -C /home/

切记标签时xvf没有z,因为这不是一个文件压缩包

在这里插入图片描述

使用rpm命令安装组件,安装需要按照依赖关系来安装,关系为:commonlibsclientserver,安装命令如下

rpm -ivh mysql-community-common-5.7.22-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.22-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.22-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.22-1.el7.x86_64.rpm

其中安装命令中的ivh含义分别是:i:install安装,v:verbose进度条,h:hash哈希值校验

跳转顶部


安装过程中可能出现的问题

在安装mysql-community-libs-5.7.22-1.el7.x86_64.rpm可能会报下列错误

warning: mysql-community-libs-5.7.22-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
	mysql-community-common(x86-64) >= 5.7.9 is needed by mysql-community-libs-5.7.22-1.el7.x86_64
	mariadb-libs is obsoleted by mysql-community-libs-5.7.22-1.el7.x86_64

解决办法是清除yum中的mysql依赖

yum remove mysql-libs
[root@hr mysql]# yum remove mysql-libs
Loaded plugins: fastestmirror
Resolving Dependencies
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.56-2.el7 will be erased
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
--> Running transaction check
---> Package postfix.x86_64 2:2.10.1-6.el7 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================================================================================================================================
 Package                                             Arch                                          Version                                                Repository                                        Size
=================================================================================================================================================================================================================
Removing:
 mariadb-libs                                        x86_64                                        1:5.5.56-2.el7                                         @anaconda                                        4.4 M
Removing for dependencies:
 postfix                                             x86_64                                        2:2.10.1-6.el7                                         @anaconda                                         12 M

Transaction Summary
=================================================================================================================================================================================================================
Remove  1 Package (+1 Dependent package)

Installed size: 17 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : 2:postfix-2.10.1-6.el7.x86_64                                                                                                                                                                 1/2 
  Erasing    : 1:mariadb-libs-5.5.56-2.el7.x86_64                                                                                                                                                            2/2 
  Verifying  : 1:mariadb-libs-5.5.56-2.el7.x86_64                                                                                                                                                            1/2 
  Verifying  : 2:postfix-2.10.1-6.el7.x86_64                                                                                                                                                                 2/2 

Removed:
  mariadb-libs.x86_64 1:5.5.56-2.el7                                                                                                                                                                             

Dependency Removed:
  postfix.x86_64 2:2.10.1-6.el7                                                                                                                                                                                  

Complete!


在安装mysql-community-server-5.7.22-1.el7.x86_64.rpm时可能会报下列错误

warning: mysql-community-server-5.7.22-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
	/usr/bin/perl is needed by mysql-community-server-5.7.22-1.el7.x86_64
	perl(Getopt::Long) is needed by mysql-community-server-5.7.22-1.el7.x86_64
	perl(strict) is needed by mysql-community-server-5.7.22-1.el7.x86_64

原因是 MySQL依赖libaio,所以先要安装libaio,安装命令如下

yum -y install libaio

如果还不可以,则使用下面的命令

 rpm -ivh --nodeps  mysql-community-server-5.7.22-1.el7.x86_64.rpm

可能原因:重复安装,需要卸载重新安装


这个时候继续安装即可

[root@hr mysql]# rpm -ivh mysql-community-common-5.7.22-1.el7.x86_64.rpm
warning: mysql-community-common-5.7.22-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-common-5.7.22-1.e################################# [100%]
[root@hr mysql]# rpm -ivh mysql-community-libs-5.7.22-1.el7.x86_64.rpm
warning: mysql-community-libs-5.7.22-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-libs-5.7.22-1.el7################################# [100%]
[root@hr mysql]# rpm -ivh mysql-community-client-5.7.22-1.el7.x86_64.rpm
warning: mysql-community-client-5.7.22-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-client-5.7.22-1.e################################# [100%]
[root@hr mysql]# rpm -ivh --nodeps  mysql-community-server-5.7.22-1.el7.x86_64.rpm
warning: mysql-community-server-5.7.22-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-server-5.7.22-1.e################################# [100%]

跳转顶部


登录并且创建密码

启动MySQL服务

systemctl start mysqld.service    启动mysql
systemctl status mysqld.service  查看mysql状态
systemctl stop mysqld.service   关闭mysql

在这里插入图片描述

查看mysql进程 ps -ef|grep mysql
查看3306端口 netstat -anop|grep 3306

在这里插入图片描述


找到临时密码

grep 'temporary password' /var/log/mysqld.log

在这里插入图片描述
临时密码就是E&g2oAlzd0fd


由于MySQL密码是有一定的要求的,但是我们在用作与学习是不需要太过复杂的密码,密码过于复杂还可能导致自己忘记,所以,我们在这可以更改密码的策略

此时,新密码长度大于等于8位才有效,否则报错

set global validate_password_policy=0;

这是设置最小的长度,但是不关你设置的是1,2,3还是4,它的最小有效长度都为4

set global validate_password_length=1;

现在来更改密码

set password for root@localhost=password('123456');

远程访问权限

这时我们在本机使用MySQL是没有问题的,但是当我们远程连接时,就会出现下列的报错

在这里插入图片描述

所以我们需要开启远程访问的权限

mysql> grant all privileges on *.* to root@'%' identified by '123456';
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

这时候在从远程访问

在这里插入图片描述
跳转顶部


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值