首页 > 数据库 >yum安装指定版本mysql

yum安装指定版本mysql

时间:2024-04-17 14:23:14浏览次数:35  
标签:禁用 mysql Community source yum community 版本 MySQL

参考链接:https://blog.csdn.net/Sunny_Future/article/details/105345493

参考链接:https://dev.mysql.com/doc/refman/8.0/en/linux-installation-yum-repo.html

安装好依赖环境
yum install -y yum-utils wget
下载仓库包
wget https://dev.mysql.com/get/mysql80-community-release-el7-5.noarch.rpm
安装仓库包

# rpm -ivh mysql80-community-release-el7-5.noarch.rpm  --no-check-certificate
# 解决报错如,Check that the correct key URLs are configured for this repository.
# rpm --import http://repo.mysql.com/RPM-GPG-KEY-mysql-2022  
# rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022

更新 yum仓
yum makecache
查看可用版本
yum repolist all | grep mysql
默认开启最新版本enabled,需要改成需要的版本

mysql-cluster-7.5-community/x86_64  MySQL Cluster 7.5 Community     禁用
mysql-cluster-7.5-community-source  MySQL Cluster 7.5 Community - S 禁用
mysql-cluster-7.6-community/x86_64  MySQL Cluster 7.6 Community     禁用
mysql-cluster-7.6-community-source  MySQL Cluster 7.6 Community - S 禁用
mysql-cluster-8.0-community/x86_64  MySQL Cluster 8.0 Community     禁用
mysql-cluster-8.0-community-source  MySQL Cluster 8.0 Community - S 禁用
mysql-connectors-community/x86_64   MySQL Connectors Community      启用:    192
mysql-connectors-community-source   MySQL Connectors Community - So 禁用
mysql-tools-community/x86_64        MySQL Tools Community           启用:     90
mysql-tools-community-source        MySQL Tools Community - Source  禁用
mysql-tools-preview/x86_64          MySQL Tools Preview             禁用
mysql-tools-preview-source          MySQL Tools Preview - Source    禁用
mysql55-community/x86_64            MySQL 5.5 Community Server      禁用
mysql55-community-source            MySQL 5.5 Community Server - So 禁用
mysql56-community/x86_64            MySQL 5.6 Community Server      禁用
mysql56-community-source            MySQL 5.6 Community Server - So 禁用
mysql57-community/x86_64            MySQL 5.7 Community Server      禁用
mysql57-community-source            MySQL 5.7 Community Server - So 禁用
mysql80-community/x86_64            MySQL 8.0 Community Server      启用:    343
mysql80-community-source            MySQL 8.0 Community Server - So 禁用

修改为需要的版本,我这里用5.7,即禁用yum存储库中mysql不需要的版本和开启需要的版本

yum-config-manager --disable mysql80-community
yum-config-manager --enable mysql57-community

查看需要的版本是否enabled
yum repolist all | grep mysql

mysql-cluster-7.5-community/x86_64  MySQL Cluster 7.5 Community     禁用
mysql-cluster-7.5-community-source  MySQL Cluster 7.5 Community - S 禁用
mysql-cluster-7.6-community/x86_64  MySQL Cluster 7.6 Community     禁用
mysql-cluster-7.6-community-source  MySQL Cluster 7.6 Community - S 禁用
mysql-cluster-8.0-community/x86_64  MySQL Cluster 8.0 Community     禁用
mysql-cluster-8.0-community-source  MySQL Cluster 8.0 Community - S 禁用
mysql-connectors-community/x86_64   MySQL Connectors Community      启用:    192
mysql-connectors-community-source   MySQL Connectors Community - So 禁用
mysql-tools-community/x86_64        MySQL Tools Community           启用:     90
mysql-tools-community-source        MySQL Tools Community - Source  禁用
mysql-tools-preview/x86_64          MySQL Tools Preview             禁用
mysql-tools-preview-source          MySQL Tools Preview - Source    禁用
mysql55-community/x86_64            MySQL 5.5 Community Server      禁用
mysql55-community-source            MySQL 5.5 Community Server - So 禁用
mysql56-community/x86_64            MySQL 5.6 Community Server      禁用
mysql56-community-source            MySQL 5.6 Community Server - So 禁用
mysql57-community/x86_64            MySQL 5.7 Community Server      启用:    584
mysql57-community-source            MySQL 5.7 Community Server - So 禁用
mysql80-community/x86_64            MySQL 8.0 Community Server      禁用
mysql80-community-source            MySQL 8.0 Community Server - So 禁用

安装mysql
yum install mysql-community-server -y
启动mysql
systemctl start mysqld
5.7版本mysql第一次启动自动生成临时密码,需要修改后才能正常使用

## 查看临时密码
# grep 'temporary password' /var/log/mysqld.log

## 登录mysql
# mysql -uroot -p

## 修改密码
# mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '这里是密码';
Query OK, 0 rows affected (0.00 sec)

然后重启修改配置文件,datadir=/data/mysql

cp -r /var/lib/mysql /data/
chown -R mysql:mysql /data/mysql/

标签:禁用,mysql,Community,source,yum,community,版本,MySQL
From: https://www.cnblogs.com/wszzn/p/18140628

相关文章

  • ubuntu安装mysql
    ubuntu安装mysql方法一、使用apt仓库更新软件列表aptupdate查看可用的MySQL版本aptlist|grepmysql-server或者aptsearchmysql-server安装指定版本的MySQL服务器aptinstallmysql-server-<version>例如安装8.0aptinstallmysql-server-8.0使用......
  • mysql8修改数据目录
    mysql8修改数据目录停止mysqlsystemctlstopmysqld修改配置文件/etc/my.cnf#datadir=/var/lib/mysql#socket=/var/lib/mysql/mysql.sockdatadir=/data/mysqlsocket=/data/mysql/mysql.sock迁移数据文件mkdir/datarsync-az/var/lib/mysql/data/创建socke......
  • mysql8.0忘记密码后重置密码
    免密验证修改配置文件vim/etc/mysql/mysql.conf.d/mysqld.cnf在配置文件中添加一行skip-grant-tables重启mysqlsystemctlrestartmysql登录mysqlmysql-uroot-p,提示输入密码直接回车即可将密码清空,然后退出usemysql;updateusersetauthentication_string=''wher......
  • mysql导出表结构
    导出整个库mysqldump--opt-dyjtxz-uroot-p>yjtxz.sql导出单个表mysqldump-uroot-p-dyjtxzhs_risk>hs_risk.sql导出数据到文件select*fromblade_deptlimit1intooutfile'/var/lib/mysql-files/blade_dept.txt';把数据库的表结构导出Excel格式,在工具里把......
  • mysql备份与恢复
    mysqldump默认没有存储过程函数触发器等的信息,是不导出的mysqldump备份表mysqldump-u用户名-p数据库名表名>备份文件路径mysqldump-uroot-pbbba>ccc.a.sqlmysqldump恢复表mysqldump-u用户名-p数据库名<备份文件路径mysqldump-uroot-pbbb<ccc.a......
  • 小版本升级(pxc)
    配置yum仓库,可以通过yum下载pxcyuminstall-yhttps://repo.percona.com/yum/percona-release-latest.noarch.rpm关闭数据库systemctlstopmysql升级:sudoyumupdatePercona-XtraDB-Cluster-57以单节点模式启动服务sudomysqld--skip-grant-tables--user=mysql--w......
  • mysql锁表查询
    一、查询所有进程showfullprocesslist;字段说明id列,用户登录mysql时,系统分配的"connection_id",可以使用函数connection_id()查看user列,显示当前用户。如果不是root,这个命令就只显示用户权限范围的sql语句host列,显示这个语句是从哪个ip的哪个端口上发的,可以用来跟踪出现......
  • mysql如何批量kill慢查询
    原文链接:https://blog.csdn.net/lanyang123456/article/details/122277340Slowquery慢查询是指执行很慢的SQL语句。一般会设置一个阈值,例如,100ms,执行时间超过100ms的都会判定为慢查询。慢查询是一种危险的信号,MySQL服务可能很快不可用。当大量出现的时候,应该立即kill。......
  • mysql5.7配置文件
    datadir=/data/mysqlsocket=/var/lib/mysql/mysql.sockDisablingsymbolic-linksisrecommendedtopreventassortedsecurityriskssymbolic-links=0log-error=/data/mysql/mysqld.logpid-file=/data/mysql/mysqld/mysqld.piddefault-time-zone='+8:00'......
  • mysql锁表解锁
    锁表语句LOCKTABLEStbl_nameREAD;锁表怎么解决?MySQL锁表怎么解锁?#1.查进程,主要是查找被锁表的那个进程的IDSHOWPROCESSLIST;#2.kill掉锁表的进程IDKILL10866;//后面的数字是进程的ID====================--锁表解决方法showfullprocesslist;--显示完整......