MySQL & Hive 安装
MySQL
MySQL安装
下载MySQL:https://www.mysql.com/
1、rpm package:是某个特定的包,比如server,client,shared lib等 ,可以单独安装 2、rpm bundle:是该版本所有包的集合, 一般是把服务器端要用的都安装上,其他的不带,尤其是开发包 3、Compressed TAR Archive,是源码,必须用源码方式安装。这个是源码,需要自己编译的,也有编译好,但不是安装包的
-
只需在一台主机上安装,我们安装在master上
-
上传至master的/opt/software下
-
卸载Mariadb
#查找mariadb [root@master softwares]# rpm -qa | grep mariadb mariadb-libs-5.5.68-1.el7.x86_64 您在 /var/spool/mail/root 中有新邮件 [root@master softwares]# rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64 [root@master softwares]# -
安装libaio
#libaio是Linux内核异步I/O(AIO)。通过提供一个接口来在一个系统调用中提交一个或多个I/O请求而无需等待完成,AIO甚至使单个应用程序线程能够将I/O操作与其他处理重叠,并通过一个单独的接口来获得已完成的I/O操作与给定的完成组相关联。在Ubuntu中,像mysql(数据库引擎)和qemu(虚拟机)这样广为人知的应用程序都依赖于此库。 #在master上安装libaio # yum -y install libaio -
安装目录: /opt/software/mysql ,解压并安装mysql
# mkdir /opt/software/mysql # cd /opt/software #解压到mysql文件夹下 [root@master softwares]# tar -xvf mysql-5.7.17-1.el7.x86_64.rpm-bundle.tar -C /opt/softwares/mysql mysql-community-embedded-compat-5.7.17-1.el7.x86_64.rpm mysql-community-libs-5.7.17-1.el7.x86_64.rpm mysql-community-common-5.7.17-1.el7.x86_64.rpm mysql-community-devel-5.7.17-1.el7.x86_64.rpm mysql-community-client-5.7.17-1.el7.x86_64.rpm mysql-community-server-5.7.17-1.el7.x86_64.rpm mysql-community-libs-compat-5.7.17-1.el7.x86_64.rpm mysql-community-server-minimal-5.7.17-1.el7.x86_64.rpm mysql-community-embedded-devel-5.7.17-1.el7.x86_64.rpm mysql-community-test-5.7.17-1.el7.x86_64.rpm mysql-community-minimal-debuginfo-5.7.17-1.el7.x86_64.rpm mysql-community-embedded-5.7.17-1.el7.x86_64.rpm [root@master softwares]# [root@master softwares]# [root@master softwares]# rpm -ivh mysql-community-common-5.7.17-1.el7.x86_64.rpm 错误:打开 mysql-community-common-5.7.17-1.el7.x86_64.rpm 失败: 没有那个文件或目录 [root@master softwares]# rpm -ivh mysql-community-common-5.7.17-1.el7.x86_64.rpm 错误:打开 mysql-community-common-5.7.17-1.el7.x86_64.rpm 失败: 没有那个文件或目录 [root@master softwares]# cd mysql [root@master mysql]# rpm -ivh mysql-community-common-5.7.17-1.el7.x86_64.rpm 警告:mysql-community-common-5.7.17-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY 准备中... ################################# [100%] 正在升级/安装... 1:mysql-community-common-5.7.17-1.e################################# [100%] [root@master mysql]# rpm -ivh mysql-community-libs-5.7.17-1.el7.x86_64.rpm 警告:mysql-community-libs-5.7.17-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY 准备中... ################################# [100%] 正在升级/安装... 1:mysql-community-libs-5.7.17-1.el7################################# [100%] [root@master mysql]# rpm -ivh mysql-community-client-5.7.17-1.el7.x86_64.rpm 警告:mysql-community-client-5.7.17-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY 准备中... ################################# [100%] 正在升级/安装... 1:mysql-community-client-5.7.17-1.e################################# [100%] [root@master mysql]# rpm -ivh mysql-community-server-5.7.17-1.el7.x86_64.rpm 警告:mysql-community-server-5.7.17-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY 错误:依赖检测失败: /usr/bin/perl 被 mysql-community-server-5.7.17-1.el7.x86_64 需要 net-tools 被 mysql-community-server-5.7.17-1.el7.x86_64 需要 perl(Getopt::Long) 被 mysql-community-server-5.7.17-1.el7.x86_64 需要 perl(strict) 被 mysql-community-server-5.7.17-1.el7.x86_64 需要 [root@master mysql]# rpm -ivh mysql-community-server-5.7.17-1.el7.x86_64.rpm -nodeps rpm: -nodeps: 未知的选项 [root@master mysql]# rpm -ivh mysql-community-server-5.7.17-1.el7.x86_64.rpm --nodeps 警告:mysql-community-server-5.7.17-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY 准备中... ################################# [100%] 正在升级/安装... 1:mysql-community-server-5.7.17-1.e################################# [100%] [root@master mysql]#
//依次安装mysql插件,安装顺序不能错
[root@master mysql]#rpm -ivh mysql-community-common-5.7.17-1.el7.x86_64.rpm
[root@master mysql]# rpm -ivh mysql-community-libs-5.7.17-1.el7.x86_64.rpm
[root@master mysql]# rpm -ivh mysql-community-client-5.7.17-1.el7.x86_64.rpm
[root@master mysql]# rpm -ivh mysql-community-server-5.7.17-1.el7.x86_64.rpm
mysql-community-libs mysql依赖lib,mysql-community-client client是DBMS面向用户,mysql-community-server mysql数据库系统,如果安装mysql-community-server 提示缺少perl,使用yum install perl 即可,中途安装提示缺少文件,按照要求使用yum 安装即可
-
删除 /etc/my.cnf 文件中的 datadir 参数所指路径 /var/lib/mysql 下的所有文件,如果存在的话
正常来说,安装成功 /var/lib/mysql下是空的
[root@master mysql]# vi /etc/my.cnf [root@master mysql]# cd /var/lib/mysql [root@master mysql]# ls -
mysql初始化设置
#为了保证数据库目录与文件的所有者为 mysql 登录用户,即初始化时创建的文件及目录的用户和组都是mysql [root@master mysql]# mysqld --initialize --user=mysql #/var/lib/mysql检查如果这个目录下面就东西就要删除,注意修改路径所有文件夹归属 #mysqld --initialize会在日志里打印出一个随机密码, # mysqld --initialize #初始化完成后 /var/lib/mysql 路径下会初始化得到一些数据库文件,文件及目录权限是root:root -rw-r-----. 1 root root 56 10月 21 21:06 auto.cnf -rw-r-----. 1 root root 413 10月 21 21:06 ib_buffer_pool -rw-r-----. 1 root root 12582912 10月 21 21:06 ibdata1 -rw-r-----. 1 root root 50331648 10月 21 21:06 ib_logfile0 -rw-r-----. 1 root root 50331648 10月 21 21:06 ib_logfile1 drwxr-x---. 2 root root 4096 10月 21 21:06 mysql drwxr-x---. 2 root root 8192 10月 21 21:06 performance_schema drwxr-x---. 2 root root 8192 10月 21 21:06 sys #更改文件及目录的用户和组为mysql # chown mysql:mysql /var/lib/mysql -R #该代码块作用与上方代码块作用相同,任用一个即可
#启动mysql服务 [root@master mysql]# systemctl start mysqld.service [root@master mysql]# #查看临时密码,密码是初始化的时候随机产生的 [root@master mysql]# cat /var/log/mysqld.log 2022-11-17T14:30:36.937533Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2022-11-17T14:30:37.827442Z 0 [Warning] InnoDB: New log files created, LSN=45790 2022-11-17T14:30:37.894375Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2022-11-17T14:30:38.020108Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 67b84c2f-6684-11ed-a8a6-000c299e8b0d. 2022-11-17T14:30:38.020872Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 2022-11-17T14:30:38.021222Z 1 [Note] A temporary password is generated for root@localhost: pM%d?ff?j7fz 2022-11-17T14:33:27.071676Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2022-11-17T14:33:27.073108Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.17) starting as process 25980 ... 2022-11-17T14:33:27.075557Z 0 [Note] InnoDB: PUNCH HOLE support available 2022-11-17T14:33:27.075577Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2022-11-17T14:33:27.075580Z 0 [Note] InnoDB: Uses event mutexes 2022-11-17T14:33:27.075582Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier 2022-11-17T14:33:27.075584Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3 2022-11-17T14:33:27.075586Z 0 [Note] InnoDB: Using Linux native AIO 2022-11-17T14:33:27.075761Z 0 [Note] InnoDB: Number of pools: 1 2022-11-17T14:33:27.075924Z 0 [Note] InnoDB: Using CPU crc32 instructions 2022-11-17T14:33:27.077284Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M 2022-11-17T14:33:27.083261Z 0 [Note] InnoDB: Completed initialization of buffer pool 2022-11-17T14:33:27.089109Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority(). 2022-11-17T14:33:27.101676Z 0 [Note] InnoDB: Highest supported file format is Barracuda. 2022-11-17T14:33:27.106661Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables 2022-11-17T14:33:27.106704Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ... 2022-11-17T14:33:27.121335Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB. 2022-11-17T14:33:27.121971Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active. 2022-11-17T14:33:27.121981Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active. 2022-11-17T14:33:27.122113Z 0 [Note] InnoDB: Waiting for purge to start 2022-11-17T14:33:27.173365Z 0 [Note] InnoDB: 5.7.17 started; log sequence number 2534561 2022-11-17T14:33:27.173598Z 0 [Note] Plugin 'FEDERATED' is disabled. 2022-11-17T14:33:27.176500Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key 2022-11-17T14:33:27.179524Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool 2022-11-17T14:33:27.180443Z 0 [Note] InnoDB: Buffer pool(s) load completed at 221117 22:33:27 2022-11-17T14:33:27.198847Z 0 [Note] Server hostname (bind-address): '*'; port: 3306 2022-11-17T14:33:27.199237Z 0 [Note] IPv6 is available. 2022-11-17T14:33:27.199275Z 0 [Note] - '::' resolves to '::'; 2022-11-17T14:33:27.199292Z 0 [Note] Server socket created on IP: '::'. 2022-11-17T14:33:27.205583Z 0 [Note] Event Scheduler: Loaded 0 events 2022-11-17T14:33:27.205681Z 0 [Note] Executing 'SELECT * FROM INFORMATION_SCHEMA.TABLES;' to get a list of tables using the deprecated partition engine. You may use the startup option '--disable-partition-engine-check' to skip this check. 2022-11-17T14:33:27.205686Z 0 [Note] Beginning of list of non-natively partitioned tables 2022-11-17T14:33:27.211403Z 0 [Note] End of list of non-natively partitioned tables 2022-11-17T14:33:27.211441Z 0 [Note] /usr/sbin/mysqld: ready for connections. Version: '5.7.17' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Community Server (GPL) [root@master mysql]#
-
修改root密码, 授权远程访问,设置开机自启动
#登录 mysql # mysql -u root -p Enter password: #这里输入在日志中生成的临时密码 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.7.17 Copyright (c) 2000, 2016, 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> #更新root密码,设置为root mysql> alter user user() identified by "root"; Query OK, 0 rows affected (0.00 sec) #也可以使用 set password = password('root'); 重设root用户密码为root #授权root用户远程登录 mysql> use mysql; ############################################################此处root是登录密码########## mysql> grant all privileges on *.* to root@'%' identified by 'root' with grant option; #也可以使用 update mysql.user set host = '%' where user = 'root'; 授权root用户远程登录 #mysql用户数据和权限有修改后,希望在"不重启MySQL服务"的情况下直接生效,那么就需要执行这个命令 mysql> flush privileges; #mysql的启动和关闭 状态查看 (这几个命令必须记住) # systemctl stop mysqld # systemctl status mysqld # systemctl start mysqld #mysql默认为开机自启动服务,如果因为3306端口被占用等原因可能会起不来。 #如果mysql开机没启动起来的话,可以手动设置自启动。 # systemctl enable mysqld #查看是否已经设置自启动成功 # systemctl list-unit-files | grep mysqld mysqld.service enabled mysqld@.service disabled [root@master mysql]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.7.17 Copyright (c) 2000, 2016, 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> alter user user() identified by "root"; Query OK, 0 rows affected (0.00 sec) 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 mysql> grant all privileges on *.* to root@'%' identified by 'root' with grant option; Query OK, 0 rows affected, 1 warning (0.01 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql> systemctl status mysqld -> ^C mysql> -
如果在Centos7.9环境下安装失败,干净卸载mysql 5.7.17的步骤
#关闭mysql服务 systemctl stop mysqld.service #查找安装mysql的rpm包 # rpm -qa | grep -i mysql mysql-community-libs-5.7.29-1.el7.x86_64 mysql-community-common-5.7.29-1.el7.x86_64 mysql-community-client-5.7.29-1.el7.x86_64 mysql-community-server-5.7.29-1.el7.x86_64 #卸载 # yum remove mysql-community-libs-5.7.29-1.el7.x86_64 mysql-community-common-5.7.29-1.el7.x86_64 mysql-community-client-5.7.29-1.el7.x86_64 mysql-community-server-5.7.29-1.el7.x86_64 #查看是否卸载干净 #rpm -qa | grep -i mysql #查找mysql相关目录 删除 # 根目录开始查找mysql相关文件 # find / -name mysql /var/lib/mysql /var/lib/mysql/mysql /usr/share/mysql # rm -rf /var/lib/mysql # rm -rf /var/lib/mysql/mysql # rm -rf /usr/share/mysql #删除默认配置及日志 # rm -rf /etc/my.cnf # rm -rf /var/log/mysqld.log -
Hive的安装
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 提示词工程——AI应用必不可少的技术
· 字符编码:从基础到乱码解决
· 地球OL攻略 —— 某应届生求职总结