当前位置: 首页 > news >正文

mySql-Linux-安装

mySql-Linux-通过YUM安装

下载 yum 源

[root@spark ~]# wget http://repo.mysql.com/mysql80-community-release-el7-3.noarch.rpm
--2023-07-31 22:51:21--  http://repo.mysql.com/mysql80-community-release-el7-3.noarch.rpm
正在解析主机 repo.mysql.com (repo.mysql.com)... 23.207.40.230
正在连接 repo.mysql.com (repo.mysql.com)|23.207.40.230|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:26024 (25K) [application/x-redhat-package-manager]
正在保存至: “mysql80-community-release-el7-3.noarch.rpm”100%[============================================================================================>] 26,024      8.35KB/s 用时 3.0s   2023-07-31 22:51:25 (8.35 KB/s) - 已保存 “mysql80-community-release-el7-3.noarch.rpm” [26024/26024])[root@spark ~]# ls
anaconda-ks.cfg       mysql80-community-release-el7-3.noarch.rpm  公共  视频  文档  音乐
initial-setup-ks.cfg  start-cluster.sh                            模板  图片  下载  桌面
[root@spark ~]# 

安装mysql Yum源

[root@spark ~]# yum install mysql80-community-release-el7-3.noarch.rpm
已加载插件:fastestmirror, langpacks
正在检查 mysql80-community-release-el7-3.noarch.rpm: mysql80-community-release-el7-3.noarch
mysql80-community-release-el7-3.noarch.rpm 将被安装
正在解决依赖关系
--> 正在检查事务
---> 软件包 mysql80-community-release.noarch.0.el7-3 将被 安装
--> 解决依赖关系完成
base/7/x86_64                                                                                                  | 3.6 kB  00:00:00     
docker-ce-stable/7/x86_64                                                                                      | 3.5 kB  00:00:00     
docker-ce-stable/7/x86_64/primary_db                                                                           | 116 kB  00:00:00     
extras/7/x86_64                                                                                                | 2.9 kB  00:00:00     
extras/7/x86_64/primary_db                                                                                     | 250 kB  00:00:00     
updates/7/x86_64                                                                                               | 2.9 kB  00:00:00     
updates/7/x86_64/primary_db                                                                                    |  22 MB  00:00:04     依赖关系解决======================================================================================================================================Package                               架构               版本              源                                                   大小
======================================================================================================================================
正在安装:mysql80-community-release             noarch             el7-3             /mysql80-community-release-el7-3.noarch              31 k事务概要
======================================================================================================================================
安装  1 软件包总计:31 k
安装大小:31 k
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
警告:RPM 数据库已被非 yum 程序修改。
** 发现 4 个已存在的 RPM 数据库问题, 'yum check' 输出如下:
icedtea-web-1.6.2-4.el7.x86_64 有缺少的需求 java-1.8.0-openjdk
jline-1.0-8.el7.noarch 有缺少的需求 java >= ('0', '1.5', None)
mysql-community-server-5.7.40-1.el7.x86_64 有缺少的需求 mysql-community-client(x86-64) >= ('0', '5.7.9', None)
mysql-community-server-5.7.40-1.el7.x86_64 有缺少的需求 mysql-community-common(x86-64) = ('0', '5.7.40', '1.el7')正在安装    : mysql80-community-release-el7-3.noarch                                                                            1/1 验证中      : mysql80-community-release-el7-3.noarch                                                                            1/1 已安装:mysql80-community-release.noarch 0:el7-3                                                                                            完毕!
[root@spark ~]# 

安装myql server

[root@spark ~]# yum -y install mysql-server --nogpgcheck
已加载插件:fastestmirror, langpacks
mysql-connectors-community                                                                                     | 2.6 kB  00:00:00     
mysql-tools-community                                                                                          | 2.6 kB  00:00:00     
mysql80-community                                                                                              | 2.6 kB  00:00:00     
(1/3): mysql-connectors-community/x86_64/primary_db                                                            | 100 kB  00:00:01     
(2/3): mysql-tools-community/x86_64/primary_db                                                                 |  94 kB  00:00:01     
(3/3): mysql80-community/x86_64/primary_db                                                                     | 250 kB  00:00:03     
Determining fastest mirrors* base: mirrors.aliyun.com* extras: mirrors.163.com* updates: mirrors.163.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 mysql-community-server.x86_64.0.5.7.40-1.el7 将被 升级
---> 软件包 mysql-community-server.x86_64.0.8.0.34-1.el7 将被 更新
--> 正在处理依赖关系 mysql-community-common(x86-64) = 8.0.34-1.el7,它被软件包 mysql-community-server-8.0.34-1.el7.x86_64 需要
--> 正在处理依赖关系 mysql-community-icu-data-files = 8.0.34-1.el7,它被软件包 mysql-community-server-8.0.34-1.el7.x86_64 需要
--> 正在处理依赖关系 mysql-community-client(x86-64) >= 8.0.11,它被软件包 mysql-community-server-8.0.34-1.el7.x86_64 需要
--> 正在检查事务
---> 软件包 mysql-community-client.x86_64.0.8.0.34-1.el7 将被 安装
--> 正在处理依赖关系 mysql-community-client-plugins = 8.0.34-1.el7,它被软件包 mysql-community-client-8.0.34-1.el7.x86_64 需要
--> 正在处理依赖关系 mysql-community-libs(x86-64) >= 8.0.11,它被软件包 mysql-community-client-8.0.34-1.el7.x86_64 需要
---> 软件包 mysql-community-common.x86_64.0.8.0.34-1.el7 将被 安装
---> 软件包 mysql-community-icu-data-files.x86_64.0.8.0.34-1.el7 将被 安装
--> 正在检查事务
---> 软件包 mysql-community-client-plugins.x86_64.0.8.0.34-1.el7 将被 安装
---> 软件包 mysql-community-libs.x86_64.0.8.0.34-1.el7 将被 安装
--> 解决依赖关系完成依赖关系解决======================================================================================================================================Package                                      架构                 版本                         源                               大小
======================================================================================================================================
正在更新:mysql-community-server                       x86_64               8.0.34-1.el7                 mysql80-community                64 M
为依赖而安装:mysql-community-client                       x86_64               8.0.34-1.el7                 mysql80-community                16 Mmysql-community-client-plugins               x86_64               8.0.34-1.el7                 mysql80-community               3.6 Mmysql-community-common                       x86_64               8.0.34-1.el7                 mysql80-community               666 kmysql-community-icu-data-files               x86_64               8.0.34-1.el7                 mysql80-community               2.2 Mmysql-community-libs                         x86_64               8.0.34-1.el7                 mysql80-community               1.5 M事务概要
======================================================================================================================================
安装           ( 5 依赖软件包)
升级  1 软件包总下载量:88 M
Downloading packages:
No Presto metadata available for mysql80-community
(1/6): mysql-community-client-plugins-8.0.34-1.el7.x86_64.rpm                                                  | 3.6 MB  00:00:09     
(2/6): mysql-community-common-8.0.34-1.el7.x86_64.rpm                                                          | 666 kB  00:00:01     
(3/6): mysql-community-icu-data-files-8.0.34-1.el7.x86_64.rpm                                                  | 2.2 MB  00:00:01     
(4/6): mysql-community-libs-8.0.34-1.el7.x86_64.rpm                                                            | 1.5 MB  00:00:01     
(5/6): mysql-community-client-8.0.34-1.el7.x86_64.rpm                                                          |  16 MB  00:00:27     
(6/6): mysql-community-server-8.0.34-1.el7.x86_64.rpm                                                          |  64 MB  00:00:30     
--------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                  2.0 MB/s |  88 MB  00:00:44     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction正在安装    : mysql-community-common-8.0.34-1.el7.x86_64                                                                        1/7 正在安装    : mysql-community-client-plugins-8.0.34-1.el7.x86_64                                                                2/7 正在安装    : mysql-community-libs-8.0.34-1.el7.x86_64                                                                          3/7 正在安装    : mysql-community-client-8.0.34-1.el7.x86_64                                                                        4/7 正在安装    : mysql-community-icu-data-files-8.0.34-1.el7.x86_64                                                                5/7 正在更新    : mysql-community-server-8.0.34-1.el7.x86_64                                                                        6/7 
警告:/etc/my.cnf 已建立为 /etc/my.cnf.rpmnew 清理        : mysql-community-server-5.7.40-1.el7.x86_64                                                                        7/7 验证中      : mysql-community-server-8.0.34-1.el7.x86_64                                                                        1/7 验证中      : mysql-community-client-plugins-8.0.34-1.el7.x86_64                                                                2/7 验证中      : mysql-community-icu-data-files-8.0.34-1.el7.x86_64                                                                3/7 验证中      : mysql-community-common-8.0.34-1.el7.x86_64                                                                        4/7 验证中      : mysql-community-libs-8.0.34-1.el7.x86_64                                                                          5/7 验证中      : mysql-community-client-8.0.34-1.el7.x86_64                                                                        6/7 验证中      : mysql-community-server-5.7.40-1.el7.x86_64                                                                        7/7 作为依赖被安装:mysql-community-client.x86_64 0:8.0.34-1.el7                  mysql-community-client-plugins.x86_64 0:8.0.34-1.el7                 mysql-community-common.x86_64 0:8.0.34-1.el7                  mysql-community-icu-data-files.x86_64 0:8.0.34-1.el7                 mysql-community-libs.x86_64 0:8.0.34-1.el7                   更新完毕:mysql-community-server.x86_64 0:8.0.34-1.el7                                                                                        完毕!
[root@spark ~]# 

启动 mysql

 systemctl start mysqld.service   -- 启动Mysql服务
systemctl status mysqld.service   -- 查看启动状态[root@spark03 log]# systemctl status mysql.service
Unit mysql.service could not be found.
[root@spark03 log]# systemctl status mysqld.service
● mysqld.service - MySQL ServerLoaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)Active: active (running) since 四 2023-08-03 23:35:52 CST; 29s agoDocs: man:mysqld(8)http://dev.mysql.com/doc/refman/en/using-systemd.htmlProcess: 3653 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)Main PID: 3683 (mysqld)Status: "Server is operational"CGroup: /system.slice/mysqld.service└─3683 /usr/sbin/mysqld8月 03 23:35:29 spark03 systemd[1]: Starting MySQL Server...
8月 03 23:35:52 spark03 systemd[1]: Started MySQL Server.

从上面的结果可以看到安装成功了,下面进入mysql

[root@spark03 log]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 8.0.34Copyright (c) 2000, 2023, Oracle and/or its affiliates.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> 

注意:这里进入mysql你发现是要输入密码的,密码就在我们的安装日志/var/log/mysqld.log中

[root@spark03 ~]# cat /var/log/mysqld.log| grep password
2022-11-20T13:07:31.778685Z 1 [Note] A temporary password is generated for root@localhost: h.:qPyt4CYq5
2022-11-20T15:10:33.238231Z 0 [Note] Shutting down plugin 'validate_password'
2022-11-20T15:10:35.019329Z 0 [Note] Shutting down plugin 'sha256_password'
2022-11-20T15:10:35.019332Z 0 [Note] Shutting down plugin 'mysql_native_password'
2023-05-20T13:53:36.968108Z 0 [Note] Shutting down plugin 'validate_password'
2023-05-20T13:53:38.451431Z 0 [Note] Shutting down plugin 'sha256_password'
2023-05-20T13:53:38.451433Z 0 [Note] Shutting down plugin 'mysql_native_password'
2023-07-31T15:30:25.134995Z 0 [Note] Shutting down plugin 'validate_password'
2023-07-31T15:30:26.483792Z 0 [Note] Shutting down plugin 'sha256_password'
2023-07-31T15:30:26.483794Z 0 [Note] Shutting down plugin 'mysql_native_password'
2023-08-03T15:35:37.029129Z 0 [Warning] [MY-013129] [Server] A message intended for a client cannot be sent there as no client-session is attached. Therefore, we're sending the information to the error-log instead: MY-001287 - 'validate password plugin' is deprecated and will be removed in a future release. Please use validate_password component instead
2023-08-03T15:37:23.094902Z 11 [Warning] [MY-013360] [Server] Plugin mysql_native_password reported: ''mysql_native_password' is deprecated and will be removed in a future release. Please use caching_sha2_password instead'
[root@spark03 ~]# date
2023年 08月 03日 星期四 23:40:02 CST

安装 问题记录

安装过程中报错,报错记录如下:

[root@spark ~]# systemctl status mysqld.service
● mysqld.service - MySQL ServerLoaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)Active: failed (Result: exit-code) since 一 2023-07-31 22:58:53 CST; 14s agoDocs: man:mysqld(8)http://dev.mysql.com/doc/refman/en/using-systemd.htmlProcess: 2997 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS (code=exited, status=1/FAILURE)Process: 2960 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)Main PID: 2997 (code=exited, status=1/FAILURE)Status: "Server shutdown complete"Error: 2 (没有那个文件或目录)731 22:58:53 spark mysqld[2997]: 2023-07-31T14:58:53.664906Z 0 [Warning] [MY-010091] [Server] Can't create test file /op...er-test
7月 31 22:58:53 spark mysqld[2997]: 2023-07-31T14:58:53.664918Z 0 [Warning] [MY-010091] [Server] Can't create test file /op...er-test
731 22:58:53 spark mysqld[2997]: 2023-07-31T14:58:53.665502Z 0 [Warning] [MY-010122] [Server] One can only use the --use...as root
731 22:58:53 spark mysqld[2997]: 2023-07-31T14:58:53.665614Z 0 [ERROR] [MY-013276] [Server] Failed to set datadir to '/o...ectory)
731 22:58:53 spark mysqld[2997]: 2023-07-31T14:58:53.665724Z 0 [ERROR] [MY-010119] [Server] Aborting
731 22:58:53 spark mysqld[2997]: 2023-07-31T14:58:53.666134Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown ... - GPL.
731 22:58:53 spark systemd[1]: mysqld.service: main process exited, code=exited, status=1/FAILURE
731 22:58:53 spark systemd[1]: Failed to start MySQL Server.
731 22:58:53 spark systemd[1]: Unit mysqld.service entered failed state.
731 22:58:53 spark systemd[1]: mysqld.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

报错原因,我的报错是因为以前用安装包安装过,所以在 /etc/my.cnf 下就已经生成了my.cnf

[root@spark opt]# systemctl status mysqld.service
● mysqld.service - MySQL ServerLoaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)Active: failed (Result: exit-code) since 一 2023-07-31 23:08:29 CST; 1min 36s agoDocs: man:mysqld(8)http://dev.mysql.com/doc/refman/en/using-systemd.htmlProcess: 3372 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS (code=exited, status=1/FAILURE)Process: 3292 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)Main PID: 3372 (code=exited, status=1/FAILURE)Status: "Server shutdown complete"Error: 98 (地址已在使用)731 23:08:09 spark systemd[1]: Starting MySQL Server...
731 23:08:29 spark systemd[1]: mysqld.service: main process exited, code=exited, status=1/FAILURE
731 23:08:29 spark systemd[1]: Failed to start MySQL Server.
731 23:08:29 spark systemd[1]: Unit mysqld.service entered failed state.
731 23:08:29 spark systemd[1]: mysqld.service failed.地址被占用,
[root@spark opt]# ps -ef | grep mysql
polkitd   2146  2072  0 22:48 ?        00:00:02 mysqld
root      3453  2520  0 23:10 pts/1    00:00:00 grep --color=auto mysql
[root@spark opt]# kill -9 2146

上面杀了几次也没见成功,火了,直接暴力----卸载-删除以前的Mysql,包括文件,然后重来!!!!

the end

http://www.lryc.cn/news/108461.html

相关文章:

  • JS实现IOS标准时间(JSON时间格式)格式转yyyy-mm-dd格式
  • 【Jmeter】 Report Dashboard 生成html图形测试报告
  • 7种有效安全的网页抓取方法,如何避免被禁止?
  • flask服务生成证书文件,采用https访问,开启用户密码验证
  • 上海首个“零工”就业云平台上线
  • 面试必考精华版Leetcode104. 二叉树的最大深度
  • winform panel中放置 usercontrol ,设置usercontrol随着dpi分辨率变化
  • 更新页面无法回显
  • CS 144 Lab Four -- the TCP connection
  • 在Volo.Abp微服务中使用SignalR
  • 数据可视化(七)常用图表的绘制
  • 【ARM 常见汇编指令学习 8 - dsb sy 指令及 dsb 参数介绍】
  • YOLOv5本地模型训练报错解决
  • tomcat p12证书另存为nginx .crt证书和.key私钥
  • Docker的userland-proxy
  • uniapp封装request请求
  • Go如何构建高效API接口| 青训营
  • 【云原生K8s】二进制部署单master K8s+etcd集群
  • TRUNC(截取)函数的用法
  • IELAB-网络工程师的路由答疑10问(1)
  • OpenLayers入门,OpenLayers加载TopoJson数据,使用行政区划边界作为示例
  • 【图像去噪】基于原始对偶算法优化的TV-L1模型进行图像去噪研究(Matlab代码实现)
  • RISC-V基础之函数调用(五)函数递归调用及函数参数数量溢出(超出现有寄存器个数)约定(包含实例)
  • 力扣:48. 旋转图像(Python3)
  • HarmonyOS应用开发者基础与高级认证题库——中级篇
  • Python中实现多个列表、字典、元组、集合的连接
  • 1005 继续(3n+1)猜想
  • 基于图片、无人机、摄像头拍摄进行智能检测功能
  • Boost开发指南-4.2ignore_unused
  • 【Mybatis】XML映射文件