Hive数据仓库--centos7下安装Mysql(rpm)
结点规划
IP | Hostname | 角色 |
---|---|---|
192.168.0.104 | master | Client |
192.168.0.102 | slave1 | metastore |
192.168.0.106 | slave2 | Mysql |
搭建步骤
1、安装Mysql
1.1 解压安装包
tar -xvf mysql-5.7.25-1.el7.x86_64.rpm-bundle.tar
[root@slave2 software]# tar -xvf mysql-5.7.29-1.el7.x86_64.rpm-bundle.tar
mysql-community-embedded-devel-5.7.29-1.el7.x86_64.rpm
mysql-community-test-5.7.29-1.el7.x86_64.rpm
mysql-community-embedded-5.7.29-1.el7.x86_64.rpm
mysql-community-embedded-compat-5.7.29-1.el7.x86_64.rpm
mysql-community-libs-5.7.29-1.el7.x86_64.rpm
mysql-community-client-5.7.29-1.el7.x86_64.rpm
mysql-community-server-5.7.29-1.el7.x86_64.rpm
mysql-community-devel-5.7.29-1.el7.x86_64.rpm
mysql-community-libs-compat-5.7.29-1.el7.x86_64.rpm
mysql-community-common-5.7.29-1.el7.x86_64.rpm
您在 /var/spool/mail/root 中有新邮件
[root@slave2 software]#
1.2 使用 rpm 命令安装MySql组件
使用命令rpm -ivh {-file-name}进行安装操作。
按照依赖关系依次安装rpm包 依赖关系依次为common→libs→client→server
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
(1)首先安装mysql-community-common
(服务器和客户端库的公共文件),使用命令:
[root@slave2 software]# rpm -ivh mysql-community-common-5.7.29-1.el7.x86_64.rpm
(2)其次安装mysql-community-libs
(MySQL数据库客户端应用程序的共享库),使用命令:
[root@slave2 software]# rpm -ivh mysql-community-libs-5.7.29-1.el7.x86_64.rpm
可能会报错:mysql依赖错误
[root@slave2 software]# rpm -ivh mysql-community-libs-5.7.29-1.el7.x86_64.rpm
警告:mysql-community-libs-5.7.29-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
错误:依赖检测失败:
mysql-community-common(x86-64) >= 5.7.9 被 mysql-community-libs-5.7.29-1.el7.x86_64 需要
mariadb-libs 被 mysql-community-libs-5.7.29-1.el7.x86_64 取代
[root@slave2 software]#
解决方案:
清除yum里所有mysql依赖包
[root@slave2 software]# rpm -qa|grep mysql
[root@slave2 software]# yum remove mysql-libs
已加载插件:fastestmirror
正在解决依赖关系
--> 正在检查事务
---> 软件包 mariadb-libs.x86_64.1.5.5.65-1.el7 将被 删除
--> 正在处理依赖关系 libmysqlclient.so.18()(64bit),它被软件包 2:postfix-2.10.1-9.el7.x86_64 需要
--> 正在处理依赖关系 libmysqlclient.so.18(libmysqlclient_18)(64bit),它被软件包 2:postfix-2.10.1-9.el7.x86_64 需要
--> 正在检查事务
---> 软件包 postfix.x86_64.2.2.10.1-9.el7 将被 删除
--> 解决依赖关系完成
依赖关系解决
===========================================================================================================
Package 架构 版本 源 大小
===========================================================================================================
正在删除:
mariadb-libs x86_64 1:5.5.65-1.el7 @anaconda 4.4 M
为依赖而移除:
postfix x86_64 2:2.10.1-9.el7 @anaconda 12 M
事务概要
===========================================================================================================
移除 1 软件包 (+1 依赖软件包)
安装大小:17 M
是否继续?[y/N]:y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在删除 : 2:postfix-2.10.1-9.el7.x86_64 1/2
正在删除 : 1:mariadb-libs-5.5.65-1.el7.x86_64 2/2
验证中 : 1:mariadb-libs-5.5.65-1.el7.x86_64 1/2
验证中 : 2:postfix-2.10.1-9.el7.x86_64 2/2
删除:
mariadb-libs.x86_64 1:5.5.65-1.el7
作为依赖被删除:
postfix.x86_64 2:2.10.1-9.el7
完毕!
[root@slave2 software]#
再重新安装mysql-community-common-5.7.29-1.el7.x86_64.rpm
:
[root@slave2 software]# rpm -ivh mysql-community-common-5.7.29-1.el7.x86_64.rpm
警告:mysql-community-common-5.7.29-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:mysql-community-common-5.7.29-1.e################################# [100%]
接着安装rpm -ivh mysql-community-libs-5.7.29-1.el7.x86_64.rpm
:
[root@slave2 software]# rpm -ivh mysql-community-libs-5.7.29-1.el7.x86_64.rpm
警告:mysql-community-libs-5.7.29-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:mysql-community-libs-5.7.29-1.el7################################# [100%]
[root@slave2 software]#
(3)之后安装 mysql-community-libs-compat
(MySQL 之前版本的共享兼容库),使用命令:
[root@slave2 software]# rpm -ivh mysql-community-libs-compat-5.7.29-1.el7.x86_64.rpm
警告:mysql-community-libs-compat-5.7.29-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:mysql-community-libs-compat-5.7.2################################# [100%]
[root@slave2 software]#
(4)之后安装 mysql-community-client
(MySQL客户端应用程序和工具),使用命令:
[root@slave2 software]# rpm -ivh mysql-community-client-5.7.29-1.el7.x86_64.rpm
警告:mysql-community-client-5.7.29-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:mysql-community-client-5.7.29-1.e################################# [100%]
[root@slave2 software]#
(5)最后安装 mysql-community-server
(数据库服务器和相关工具),使用命令:
竟然能报错:
[root@slave2 software]# rpm -ivh mysql-community-server-5.7.29-1.el7.x86_64.rpm
警告:mysql-community-server-5.7.29-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
错误:依赖检测失败:
/usr/bin/perl 被 mysql-community-server-5.7.29-1.el7.x86_64 需要
libaio.so.1()(64bit) 被 mysql-community-server-5.7.29-1.el7.x86_64 需要
libaio.so.1(LIBAIO_0.1)(64bit) 被 mysql-community-server-5.7.29-1.el7.x86_64 需要
libaio.so.1(LIBAIO_0.4)(64bit) 被 mysql-community-server-5.7.29-1.el7.x86_64 需要
net-tools 被 mysql-community-server-5.7.29-1.el7.x86_64 需要
perl(Getopt::Long) 被 mysql-community-server-5.7.29-1.el7.x86_64 需要
perl(strict) 被 mysql-community-server-5.7.29-1.el7.x86_64 需要
[root@slave2 software]#
解决方案:
缺少三个Mysql依赖,使用yum安装即可
net-tools
libaio
perl
使用yum安装对应包
[root@slave2 software]# yum -y install perl.x86_64
[root@slave2 software]# yum install -y libaio.x86_64
[root@slave2 software]# yum -y install net-tools.x86_64
安装libaio
:
[root@slave2 software]# yum -y install libaio
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.163.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
正在解决依赖关系
--> 正在检查事务
---> 软件包 libaio.x86_64.0.0.3.109-13.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
===========================================================================================================
Package 架构 版本 源 大小
===========================================================================================================
正在安装:
libaio x86_64 0.3.109-13.el7 base 24 k
事务概要
===========================================================================================================
安装 1 软件包
总下载量:24 k
安装大小:38 k
Downloading packages:
libaio-0.3.109-13.el7.x86_64.rpm | 24 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
警告:RPM 数据库已被非 yum 程序修改。
正在安装 : libaio-0.3.109-13.el7.x86_64 1/1
验证中 : libaio-0.3.109-13.el7.x86_64 1/1
已安装:
libaio.x86_64 0:0.3.109-13.el7
完毕!
[root@slave2 software]#
再次检查libaio
:
[root@slave2 software]# rpm -qa|grep libaio
libaio-0.3.109-13.el7.x86_64
[root@slave2 software]#
安装net-tools
:
[root@slave2 software]# yum -y install net-tools.x86_64
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.163.com
* updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 net-tools.x86_64.0.2.0-0.25.20131004git.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
===========================================================================================================
Package 架构 版本 源 大小
===========================================================================================================
正在安装:
net-tools x86_64 2.0-0.25.20131004git.el7 base 306 k
事务概要
===========================================================================================================
安装 1 软件包
总下载量:306 k
安装大小:917 k
Downloading packages:
net-tools-2.0-0.25.20131004git.el7.x86_64.rpm | 306 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : net-tools-2.0-0.25.20131004git.el7.x86_64 1/1
验证中 : net-tools-2.0-0.25.20131004git.el7.x86_64 1/1
已安装:
net-tools.x86_64 0:2.0-0.25.20131004git.el7
完毕!
mysql-community-server-5.7.29-1.el7.x86_64.rpm
终于安装成功:
[root@slave2 software]# rpm -ivh mysql-community-server-5.7.29-1.el7.x86_64.rpm
警告:mysql-community-server-5.7.29-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:mysql-community-server-5.7.29-1.e################################# [100%]
2、登录 MySQL
1. 初始化 MySQL 的数据库
安装好 MySQL 后,我们需要初始化数据库,初始化和启动数据库时最好不要使用root用户,而是使用mysql用户启动。
[root@slave2 software]# mysqld --initialize-insecure --user=mysql
2. 启动 MySQL 服务
使用如下命令开启 MySQL 服务,让其在后台运行:
[root@slave2 software]# mysqld --user=mysql &
[1] 2965
说明:一定要加“&”,才能脚本放到后台运行。
3. 登录 MySQL
使用root用户无密码登录 MySQL:
[root@slave2 software]# mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.29 MySQL Community Server (GPL)
Copyright (c) 2000, 2020, 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.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
4. 重置 MySQL 密码
在 5.7 版本后,我们可以使用 alter user...identified by
命令把root用户的密码修改为“123456”,具体命令如下所示:
mysql> alter user 'root'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.00 sec)
修改完成,使用exit
或者quit
命令退出 MySQL,重新登录验证密码是否修改成功,具体命令如下所示:
mysql> exit
Bye
# 使用密码登录
[root@slave2 software]# mysql -uroot -p123456
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 3
Server version: 5.7.29 MySQL Community Server (GPL)
Copyright (c) 2000, 2020, 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.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
3、 增加远程登录权限
当我们的帐号不允许从远程登录,只能在localhost连接时。这个时候只要在 MySQL 服务器上,更改mysql 数据库里的 user 表里的 host 项,从localhost改成%即可实现用户远程登录。
(1)首先我们来查看 mysql 数据库下的 user表信息:
mysql> use mysql; # 切换成mysql数据库
mysql> select user,host from user; # 查询用户信息
可以看到在user表中已创建的root用户。host字段表示登录的主机,其值可以用IP地址,也可用主机名。
(2)实现远程连接(授权法)
将 host 字段的值改为%就表示在任何客户端机器上能以root用户登录到 MySQL 服务器,建议在开发时设为%。
# 设置远程登录权限
mysql> update user set host='%' where host='localhost';
# 刷新配置信息
mysql> flush privileges;
效果如下所示:
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 3
Server version: 5.7.29 MySQL Community Server (GPL)
Copyright (c) 2000, 2020, 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.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
# 1、切换成mysql数据库
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
# 2、查询用户信息
mysql> select user,host from user;
+---------------+-----------+
| user | host |
+---------------+-----------+
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
+---------------+-----------+
3 rows in set (0.00 sec)
# 3、设置远程登录权限
mysql> update user set host='%' where host='localhost';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
# 4、# 刷新配置信息
mysql> select user,host from user;
+---------------+------+
| user | host |
+---------------+------+
| mysql.session | % |
| mysql.sys | % |
| root | % |
+---------------+------+
3 rows in set (0.00 sec)
mysql>
Mysql安装部分结束…
本文地址:https://blog.csdn.net/qq_44957186/article/details/107327568
推荐阅读
-
CentOS6.5下RPM方式安装mysql5.6.33的详细教程
-
Centos7下使用yum安装mysql数据库的详细教程(增强版)
-
Linux下rpm方式安装mysql教程
-
CentOS6.5下RPM方式安装mysql5.6.33的详细教程
-
Centos7下使用yum安装mysql数据库的详细教程(增强版)
-
CentOS 7下使用RPM安装mysql5.7.13
-
CentOS7下MySQL5.7安装配置方法图文教程(YUM)
-
centos7上mysql8.0rpm方式安装教程图解
-
CentOS7下mysql 8.0.16 安装配置方法图文教程
-
Centos7下mysql 8.0.15 安装配置图文教程