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

MySQL在Centos7环境安装

说明:
安装与卸载中,⽤⼾全部切换成为root,⼀旦 安装,普通⽤⼾能使⽤的

1. 卸载不要的环境

[root@hcss-ecs-1036 ~]# ps ajx |grep mariadb # 先检查是否有mariadb存在
13134 14844 14843 13134 pts/0 14843 S+ 1005 0:00 grep --color=auto
mariadb
19010 19187 19010 19010 ? -1 Sl 27 16:55 /usr/libexec/mysqld --
basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --
log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid
--socket=/var/lib/mysql/mysql.sock
[root@hcss-ecs-1036 ~]# systemctl stop mariadb.service # 停⽌mariadb 服务
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to manage system services or units.
Authenticating as: root
Password:
==== AUTHENTICATION COMPLETE ===
[root@hcss-ecs-1036 ~]# ps axj |grep mariadb # 停⽌完成
13134 14976 14975 13134 pts/0 14975 S+ 1005 0:00 grep --color=auto
mariadb

2. 检查系统安装包

[root@hcss-ecs-1036 MySQL]# rpm -qa | grep mariadb
or

[root@hcss-ecs-1036 MySQL]# rpm -qa | grep mysql

 # 下⾯是打印出来的mysql的样例:

 3. 卸载这些默认安装包

# 卸载显⽰出来的 mariadb/mysql 安装包
[root@hcss-ecs-1036 ~]# sudo yum remove mariadb # 还是试着将上⾯的包都⼀个⼀个卸载吧
备份 /etc/my.cnf, 备份 /var/lib/mysql 数据

 4. 获取mysql官⽅yum源

# 1. 获取 mysql 官⽅ yum http://repo.mysql.com/
# ⼀定要看下⾯的⽂字!如果后⾯⾃⼰安装不成功,就看看这个
# 注意:最好安装和⾃⼰系统⼀致的 mysql 版本,否则可能会存在软件兼容性问题
# 查看⾃⼰的系统版本
# [root@VM-0-2-centos ~] # cat /etc/redhat-release
# CentOS Linux release 7.8.2003 (Core)
# 可以进⼊ http://repo.mysql.com/ , 找⼀下和⾃⼰版本⼀致的资源
# 下载到你的本地,然后上传到你的 Linux 服务器

 5. 安装mysql yum 源,对⽐前后yum源

# 安装前
[root@hcss-ecs-1036 ~]# ls
mysql57-community-release-el7-10.noarch.rpm

 查看你本地的yum[我的和你的肯定不同,但是没有mysql相关的yum]

 安装中

[root@hcss-ecs-1036 ~]# rpm -Uvh mysql57-community-release-el7-10.noarch.rpm
warning: mysql57-community-release-el7-10.noarch.rpm: Header V3 DSA/SHA1
Signature, key ID 5072e1f5: NOKEY
error: can't create transaction lock on /var/lib/rpm/.rpm.lock (Permission
denied)
# 如果上⾯出错了
[root@hcss-ecs-1036 ~]# sudo rpm -Uvh mysql57-community-release-el7-
10.noarch.rpm
[sudo] password for wmh:
warning: mysql57-community-release-el7-10.noarch.rpm: Header V3 DSA/SHA1
Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql57-community-release-el7-10 ################################# [100%]
# 安装后
[root@hcss-ecs-1036 ~]# ls /etc/yum.repos.d/ -al
total 96
drwxr-xr-x. 2 root root 4096 Apr 12 11:04 .
drwxr-xr-x. 106 root root 12288 Apr 12 10:50 ..
-rw-r--r-- 1 root root 2523 Dec 26 19:31 Centos-Base.repo
-rw-r--r-- 1 root root 614 Nov 10 18:42 CentOS-Base.repo_bak
-rw-r--r-- 1 root root 2523 Jun 16 2018 CentOS-Base.repo.bak
-rw-r--r-- 1 root root 1309 Apr 8 2020 CentOS-CR.repo
-rw-r--r-- 1 root root 649 Apr 8 2020 CentOS-Debuginfo.repo
-rw-r--r-- 1 root root 230 Nov 10 18:42 CentOS-Epel.repo
-rw-r--r-- 1 root root 314 Apr 8 2020 CentOS-fasttrack.repo
-rw-r--r-- 1 root root 630 Apr 8 2020 CentOS-Media.repo
-rw-r--r-- 1 root root 998 Dec 11 2018 CentOS-SCLo-scl.repo
-rw-r--r-- 1 root root 971 Oct 29 2018 CentOS-SCLo-scl-rh.repo
-rw-r--r-- 1 root root 1331 Apr 8 2020 CentOS-Sources.repo
-rw-r--r-- 1 root root 7577 Apr 8 2020 CentOS-Vault.repo
-rw-r--r-- 1 root root 616 Apr 8 2020 CentOS-x86_64-kernel.repo
-rw-r--r-- 1 root root 1919 Apr 8 23:57 docker-ce.repo
-rw-r--r-- 1 root root 1050 Nov 1 04:33 epel.repo
-rw-r--r-- 1 root root 1149 Nov 1 04:33 epel-testing.repo
-rw-r--r-- 1 root root 173 Dec 9 16:08 google-chrome.repo
-rw-r--r-- 1 root root 1627 Apr 5 2017 mysql-community.repo #安装了
mysql yum源
-rw-r--r-- 1 root root 1663 Apr 5 2017 mysql-community-source.repo

6. 看看能不能正常⼯作

#在看看能不能正常⼯作
[root@hcss-ecs-1036 ~]# yum list |grep mysql
Repository epel is listed more than once in the configuration
mysql57-community-release.noarch el7-10 installed
akonadi-mysql.x86_64 1.9.2-4.el7 base
anope-mysql.x86_64 2.0.9-3.el7 epel
apr-util-mysql.x86_64 1.5.2-6.el7 base
calligra-kexi-driver-mysql.x86_64 2.9.10-2.el7 epel
collectd-mysql.x86_64 5.8.1-1.el7 epel
dmlite-plugins-mysql.x86_64 1.14.2-1.el7 epel
dovecot-mysql.x86_64 1:2.2.36-8.el7 base

7. 安装mysql服务

[root@hcss-ecs-1036 ~]# sudo yum install -y mysql-community-server
[sudo] password for wmh:
Loaded plugins: aliases, auto-update-debuginfo, fastestmirror, protectbase
Repository epel is listed more than once in the configuration
...
Installing : mysql-community-common-5.7.33-1.el7.x86_64 #公共模块
Installing : mysql-community-libs-5.7.33-1.el7.x86_64 #库
Installing : mysql-community-client-5.7.33-1.el7.x86_64 #客⼾端
Installing : mysql-community-server-5.7.33-1.el7.x86_64 #服务器
... #安装了服务和客⼾端

8. 查看配置⽂件和数据存储位置

 9. 启动服务

[root@hcss-ecs-1036 ~]# systemctl start mysqld.service
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to manage system services or units.
Authenticating as: root
Password:
==== AUTHENTICATION COMPLETE ===

 10. 查看启动服务

 11. 登陆⽅法⼀【不⾏就下⼀个】

#获取临时root密码
[wmh@hcss-ecs-1036 ~]$ sudo grep 'temporary password' /var/log/mysqld.log
2021-04-12T03:23:46.153263Z 1 [Note] A temporary password is generated for
root@localhost: yLMalT:v+5l*
#使⽤临时密码登录
[wmh@hcss-ecs-1036 ~]$ mysql -uroot -p
Enter password:
#判断修改密码时候新密码是否符合当前的策略,不满⾜报错,不让修改,关闭它
#安全强度,默认为中,即1,要求必须包含 数字、符号、⼤⼩写字⺟,⻓度⾄少为8位
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)
#密码最⼩⻓度
mysql> set global validate_password_length=1;
Query OK, 0 rows affected (0.00 sec)
#修改本地登录密码,暂不授权远程登录
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'qwer@wu.888';
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
#如果你安装的最新的mysql,没有所谓的临时密码,root默认没有密码

12. 登陆⽅法⼆【不⾏就下⼀个】

# 如果你安装的最新的 mysql ,没有所谓的临时密码, root 默认没有密码
# 试着直接 client 登陆⼀下

 13. 登陆⽅式三【应该⾏了吧】

[root@bite-alicloud mysql]# vim /etc/my.cnf # 打开mysql配置⽂件
在[mysqld]最后⼀栏配置(不知道是什么,就放在配置⽂件最后) 加⼊: skip-grant-tables 选项,
并保存退出
[root@bite-alicloud mysql]# systemctl restart mysqld # 重启mysql服务
# 登陆成功
[root@bite-alicloud mysql]# mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.41 MySQL Community Server (GPL)
Copyright (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>

14. 设置开机启动[可以不设]

# 开启开机⾃启动
systemctl enable mysqld
systemctl daemon-reload

 15. 配置my.cnf

#配置⼀下my.conf,主要是数据库客⼾端和服务器的编码格式
[root@hcss-ecs-1036 ~]# cat /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
[mysql]
#default-character-set=utf8 ,暂不设置,mysql有bug,汉字不回显
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
port=3306
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
character-set-server=utf8
default-storage-engine=innodb
# 配置完毕,重启mysql即可

16. 常⻅问题:

mysql 已经配置了客⼾端服务器utf8编码,但是⽆法输⼊中⽂
确保您在终端命令⾏中可以输⼊中⽂
[root@hcss-ecs-1036 ~]# env |grep LANG
LANG=en_US.utf8
安装遇到秘钥过期的问题:
Failing package is: mysql-community-client-5.7.39-1.el7.x86_64
GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
解决⽅案:
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022

相关文章:

MySQL在Centos7环境安装

说明: • 安装与卸载中,⽤⼾全部切换成为root,⼀旦 安装,普通⽤⼾能使⽤的 1. 卸载不要的环境 [roothcss-ecs-1036 ~]# ps ajx |grep mariadb # 先检查是否有mariadb存在 13134 14844 14843 13134 pts/0 14843 S 1005 0:00 gr…...

halcon视觉缺陷检测常用的6种方法

一、缺陷检测综述 缺陷检测是视觉需求中难度最大一类需求,主要是其稳定性和精度的保证。首先常见缺陷:凹凸、污点瑕疵、划痕、裂缝、探伤等。常用的手法有六大金刚(在halcon中的ocv和印刷检测是针对印刷行业的检测,有对应算子封装): 1.blob+特征 2.blob+差分+特征 3.光度…...

openGauss学习笔记-151 openGauss 数据库运维-备份与恢复-物理备份与恢复之gs_basebackup

文章目录 openGauss学习笔记-151 openGauss 数据库运维-备份与恢复-物理备份与恢复之gs_basebackup151.1 背景信息151.2 前提条件151.3 语法151.4 示例151.5 从备份文件恢复数据 openGauss学习笔记-151 openGauss 数据库运维-备份与恢复-物理备份与恢复之gs_basebackup 151.1 …...

报错:Uncaught ReferenceError: Cannot access ‘l‘ before initialization

在文件 .babelrc 或 babel.config.js ,webpack.config.js 下配置 .babel 或 babel.config.js "plugins": ["babel/plugin-transform-runtime" ] webpack.config.js,详见 Webpack target module.exports {target: [web, es5], }...

计算机视觉-机器学习-人工智能顶会 会议地址

计算机视觉-机器学习-人工智能顶会 会议地址 最近应该要整理中文资料的参考文献,很多会议文献都需要补全会议地点(新国标要求)。四处百度感觉也挺麻烦的,而且没有比较齐全的网站可以搜索。因此自己整理了一下计算机视觉-机器学习…...

784. 字母大小写全排列

字母大小写全排列 描述 : 给定一个字符串 s ,通过将字符串 s 中的每个字母转变大小写,我们可以获得一个新的字符串。 返回 所有可能得到的字符串集合 。以 任意顺序 返回输出。 题目 : LeetCode 784.字母大小写全排列 : 784. 字母大小写全排列 分析…...

HarmonyOS鸿蒙应用开发——HTTP网络访问与封装

文章目录 基本使用封装参考 基本使用 鸿蒙应用发起HTTP请求的基本使用,如下: 导入http模块创建httpRequest对象发起http请求,并处理响应结果 第一、导入http模块: import http from ohos.net.http第二、创建httpRequest对象&a…...

vscode 编写爬虫爬取王者荣耀壁纸

网上关于爬虫大部分教程和编辑器用的都不是vscode ,此教程用到了vscode、Python、bs4、requests。 vscode配置Python安装环境可以看看这个大佬的教程 03-vscode安装和配置_哔哩哔哩_bilibili vscode配置爬虫环境可以参考这个大佬的教程【用Vscode实现简单的python…...

spring boot + uniapp 微信公众号 jsapi 支付

后端支付类 package com.ruoyi.coupon.payment;import com.google.gson.Gson; import com.ruoyi.coupon.payment.dto.PayParamJsapiDto; import com.ruoyi.coupon.payment.dto.RefundParam; import com.ruoyi.coupon.service.ICouponConfigService; import com.wechat.pay.jav…...

【数学建模】《实战数学建模:例题与讲解》第九讲-时间序列分析(含Matlab代码)

【数学建模】《实战数学建模:例题与讲解》第九讲-时间序列分析(含Matlab代码) 基本概念确定性时间序列分析方法平稳时间序列模型ARIMA模型季节性序列 习题8.11. 题目要求2.解题过程3.程序4.结果 习题8.21. 题目要求2.解题过程3.程序4.结果 习…...

大话数据结构-查找-有序表查找

注:本文同步发布于稀土掘金。 3 有序表查找 3.1 折半查找 折半查找(Binary Search)技术,又称为二分查找,它的前提是线性表中的记录必须是关键码有序(通常从小到大有序),线性表必须…...

Qt实现二维码生成和识别

一、简介 QZxing开源库: 生成和识别条码和二维码 下载地址:https://gitcode.com/mirrors/ftylitak/qzxing/tree/master 二、编译与使用 1.下载并解压,解压之后如图所示 2.编译 打开src目录下的QZXing.pro,选择合适的编译器进行编译 最后生…...

MyBatisX插件

MyBatisX插件 MyBatis-Plus为我们提供了强大的mapper和service模板,能够大大的提高开发效率。 但是在真正开发过程中,MyBatis-Plus并不能为我们解决所有问题,例如一些复杂的SQL,多表联查,我们就需要自己去编写代码和SQ…...

《C++20设计模式》学习笔记---原型模式

C20设计模式 第 4 章 原型模式4.1 对象构建4.2 普通拷贝4.3 通过拷贝构造函数进行拷贝4.4 “虚”构造函数4.5 序列化4.6 原型工厂4.7 总结4.8 代码 第 4 章 原型模式 考虑一下我们日常使用的东西,比如汽车或手机。它们并不是从零开始设计的,相反&#x…...

SpringBootAdmin设置邮件通知

如果你想要在Spring Boot Admin中配置邮件通知&#xff0c;可以按照以下步骤进行操作&#xff1a; 添加邮件通知的依赖 <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-mail</artifactId> </dep…...

深度解析IP应用场景API:提升风险控制与反欺诈能力

前言 在当今数字化时代&#xff0c;网络安全和用户数据保护成为企业日益关注的焦点。IP应用场景API作为一种强大的工具&#xff0c;不仅能够在线调用接口获取IP场景属性&#xff0c;而且具备识别IP真人度的能力&#xff0c;为企业提供了卓越的风险控制和反欺诈业务能力。本文将…...

Java连接数据库增删改查-MyBatis

准备工作&#xff1a; 1.创建一个springboot项目&#xff0c;并添加四个依赖 分别是&#xff0c;MyBatis的启动依赖和安装依赖&#xff0c;SQL的依赖&#xff0c;测试依赖&#xff0c;如下&#xff1a; 2.然后创建一张至少两条数据的表 &#xff08;表可以用各种图形化工具创…...

在国内,现在月薪1万是什么水平?

看到网友发帖问&#xff1a;现在月薪1W是什么水平&#xff1f; 在现如今的情况下&#xff0c;似乎月薪过万这个标准已经成为衡量个人能力的一个标准了&#xff0c;尤其是现在互联网横行的时代&#xff0c;好像年入百万&#xff0c;年入千万就应该是属于大众的平均水平。 我不是…...

【Python网络爬虫入门教程1】成为“Spider Man”的第一课:HTML、Request库、Beautiful Soup库

Python 网络爬虫入门&#xff1a;Spider man的第一课 写在最前面背景知识介绍蛛丝发射器——Request库智能眼镜——Beautiful Soup库 第一课总结 写在最前面 有位粉丝希望学习网络爬虫的实战技巧&#xff0c;想尝试搭建自己的爬虫环境&#xff0c;从网上抓取数据。 前面有写一…...

燕千云汇联易联袂出击:护航医企合规,丝滑内外协作

&#x1f449; 如想详细了解燕千云医药行业快速实施包&#xff08;ITFA&#xff09;&#xff0c;可继续阅读详细内容&#xff1a; 文/玉娇龙 一. 医药行业数字化挑战 医药研发从基础研究到最终注册上市的整个生命周期长则需要10多年&#xff0c;短则需要6-7年&#xff0c;在漫长…...

vue3 定时器-定义全局方法 vue+ts

1.创建ts文件 路径&#xff1a;src/utils/timer.ts 完整代码&#xff1a; import { onUnmounted } from vuetype TimerCallback (...args: any[]) > voidexport function useGlobalTimer() {const timers: Map<number, NodeJS.Timeout> new Map()// 创建定时器con…...

EtherNet/IP转DeviceNet协议网关详解

一&#xff0c;设备主要功能 疆鸿智能JH-DVN-EIP本产品是自主研发的一款EtherNet/IP从站功能的通讯网关。该产品主要功能是连接DeviceNet总线和EtherNet/IP网络&#xff0c;本网关连接到EtherNet/IP总线中做为从站使用&#xff0c;连接到DeviceNet总线中做为从站使用。 在自动…...

CRMEB 框架中 PHP 上传扩展开发:涵盖本地上传及阿里云 OSS、腾讯云 COS、七牛云

目前已有本地上传、阿里云OSS上传、腾讯云COS上传、七牛云上传扩展 扩展入口文件 文件目录 crmeb\services\upload\Upload.php namespace crmeb\services\upload;use crmeb\basic\BaseManager; use think\facade\Config;/*** Class Upload* package crmeb\services\upload* …...

[Java恶补day16] 238.除自身以外数组的乘积

给你一个整数数组 nums&#xff0c;返回 数组 answer &#xff0c;其中 answer[i] 等于 nums 中除 nums[i] 之外其余各元素的乘积 。 题目数据 保证 数组 nums之中任意元素的全部前缀元素和后缀的乘积都在 32 位 整数范围内。 请 不要使用除法&#xff0c;且在 O(n) 时间复杂度…...

全志A40i android7.1 调试信息打印串口由uart0改为uart3

一&#xff0c;概述 1. 目的 将调试信息打印串口由uart0改为uart3。 2. 版本信息 Uboot版本&#xff1a;2014.07&#xff1b; Kernel版本&#xff1a;Linux-3.10&#xff1b; 二&#xff0c;Uboot 1. sys_config.fex改动 使能uart3(TX:PH00 RX:PH01)&#xff0c;并让boo…...

pikachu靶场通关笔记22-1 SQL注入05-1-insert注入(报错法)

目录 一、SQL注入 二、insert注入 三、报错型注入 四、updatexml函数 五、源码审计 六、insert渗透实战 1、渗透准备 2、获取数据库名database 3、获取表名table 4、获取列名column 5、获取字段 本系列为通过《pikachu靶场通关笔记》的SQL注入关卡(共10关&#xff0…...

网站指纹识别

网站指纹识别 网站的最基本组成&#xff1a;服务器&#xff08;操作系统&#xff09;、中间件&#xff08;web容器&#xff09;、脚本语言、数据厍 为什么要了解这些&#xff1f;举个例子&#xff1a;发现了一个文件读取漏洞&#xff0c;我们需要读/etc/passwd&#xff0c;如…...

基于 TAPD 进行项目管理

起因 自己写了个小工具&#xff0c;仓库用的Github。之前在用markdown进行需求管理&#xff0c;现在随着功能的增加&#xff0c;感觉有点难以管理了&#xff0c;所以用TAPD这个工具进行需求、Bug管理。 操作流程 注册 TAPD&#xff0c;需要提供一个企业名新建一个项目&#…...

三分算法与DeepSeek辅助证明是单峰函数

前置 单峰函数有唯一的最大值&#xff0c;最大值左侧的数值严格单调递增&#xff0c;最大值右侧的数值严格单调递减。 单谷函数有唯一的最小值&#xff0c;最小值左侧的数值严格单调递减&#xff0c;最小值右侧的数值严格单调递增。 三分的本质 三分和二分一样都是通过不断缩…...

关于uniapp展示PDF的解决方案

在 UniApp 的 H5 环境中使用 pdf-vue3 组件可以实现完整的 PDF 预览功能。以下是详细实现步骤和注意事项&#xff1a; 一、安装依赖 安装 pdf-vue3 和 PDF.js 核心库&#xff1a; npm install pdf-vue3 pdfjs-dist二、基本使用示例 <template><view class"con…...