通过配置本地http 的mysql yum源,安装特定版本mysql。


0.ENV
CentOS7.7;
mysql 5.7.33。
1. 下载mysql
下载地址:
https://dev.mysql.com/downloads/mysql/5.7.html#downloads
Select Version:5.7.33 OR 5.6.51
Select Operating System:RHEL/OEL
Select OS Version:RHEL7/OEL7
download “RPM Bundle”:登录ORACLE账号后进行下载
OR
直接下载:
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.33-1.el7.x86_64.rpm-bundle.tar
[root@cdh1 soft]# du -sh mysql-5.7.33-1.el7.x86_64.rpm-bundle.tar
518M mysql-5.7.33-1.el7.x86_64.rpm-bundle.tar
复制
2. 上传到服务器
略。
3. 安装mysql5.7
解压mysql5.7安装包
[root@cdp1 soft]# pwd
/soft
[root@cdh1 soft]# mkdir 5.7.33
[root@cdh1 soft]# tar xvf mysql-5.7.33-1.el7.x86_64.rpm-bundle.tar -C 5.7.33
mysql-community-client-5.7.33-1.el7.x86_64.rpm
mysql-community-common-5.7.33-1.el7.x86_64.rpm
mysql-community-devel-5.7.33-1.el7.x86_64.rpm
mysql-community-embedded-5.7.33-1.el7.x86_64.rpm
mysql-community-embedded-compat-5.7.33-1.el7.x86_64.rpm
mysql-community-embedded-devel-5.7.33-1.el7.x86_64.rpm
mysql-community-libs-5.7.33-1.el7.x86_64.rpm
mysql-community-libs-compat-5.7.33-1.el7.x86_64.rpm
mysql-community-server-5.7.33-1.el7.x86_64.rpm
mysql-community-test-5.7.33-1.el7.x86_64.rpm
复制
4. 创建依赖关系
安装 createrepo
[root@cdp1 soft]# yum -y install createrepo
复制
建立yum源的依赖关系文件
[root@cdp1 ~]# createrepo soft/5.7.33/
Spawning worker 0 with 2 pkgs
Spawning worker 1 with 2 pkgs
Spawning worker 2 with 1 pkgs
Spawning worker 3 with 1 pkgs
Spawning worker 4 with 1 pkgs
Spawning worker 5 with 1 pkgs
Spawning worker 6 with 1 pkgs
Spawning worker 7 with 1 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
复制
5. http配置
如果使用http作为输出
[root@cdp1 ~]# yum -y install httpd
[root@cdp1 ~]# systemctl enable httpd
[root@cdp1 ~]# systemctl start httpd
复制
创建软链接
[root@cdp1 ~]# ln -s soft/5.7.33/ var/www/html/mysql5.7.33
复制
创建配置文件
# cat etc/yum.repos.d/cdp.repo
[db]
name=mysql5.7.33
baseurl=http://192.168.80.70/mysql5.7.33
enabled=1
gpgcheck=0
复制
查看repolist配置
# yum repolist
复制
6. 后续安装配置
6.1 安装mysql
前述已经配置了mysql httpd yum源
[root@cdp1 ~]# yum install -y mysql-community-server
复制
6.2 修改配置
[root@cdp1 ~]# cp etc/my.cnf etc/my.cnf.orig
[root@cdp1 ~]# vim etc/my.cnf #配置内容
[mysqld]
character-set-server = utf8
collation-server = utf8_general_ci
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
transaction-isolation = READ-COMMITTED
# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
symbolic-links = 0
key_buffer_size = 32M
max_allowed_packet = 16M
thread_stack = 256K
thread_cache_size = 64
# The following 3 parameters only apply to MySQL version 5.7 and lower:
query_cache_limit = 8M
query_cache_size = 64M
query_cache_type = 1
max_connections = 550
log_bin=/var/lib/mysql/mysql_binary_log
relay-log=/var/lib/mysql/relay-mysql
#In later versions of MySQL, if you enable the binary log and do not set
#a server_id, MySQL will not start. The server_id must be unique within
#the replicating group.
server_id=1
auto-increment-offset = 1
auto-increment-increment = 2
binlog_format = mixed
read_buffer_size = 2M
read_rnd_buffer_size = 16M
sort_buffer_size = 8M
join_buffer_size = 8M
# InnoDB settings
innodb_file_per_table = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 64M
innodb_buffer_pool_size = 4G
innodb_thread_concurrency = 8
innodb_flush_method = O_DIRECT
innodb_log_file_size = 512M
innodb_file_format = Barracuda
innodb_large_prefix = ON
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
复制
6.3 启动mysql服务
[root@cdp1 ~]# systemctl start mysqld
[root@cdp1 ~]# systemctl enable mysqld
复制
6.4 重置mysql密码
[root@cdp1 ~]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@cdp1 ~]# systemctl stop mysqld
复制
[root@cdp1 ~]# vim /etc/my.cnf
在[mysqld]段内最后添加
skip-grant-tables
复制
保存退出重启mysql服务
[root@cdp1 ~]# systemctl restart mysqld
[root@cdp1 ~]# mysql
mysql> use mysql
mysql> update user set authentication_string=password('Rundba_15') where user='root';
vim /etc/my.cnf #去掉参数
skip-grant-tables
复制
重启服务
[root@cdp1 ~]# systemctl restart mysqld
复制
6.5 登录数据库
[root@cdp1 ~]# mysql -uroot -pRundba_15
--完--
文章转载自rundba,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。
评论
相关阅读
【MySQL 30周年庆】MySQL 8.0 OCP考试限时免费!教你免费领考券
墨天轮小教习
2696次阅读
2025-04-25 18:53:11
MySQL 30 周年庆!MySQL 8.4 认证免费考!这次是认真的。。。
严少安
803次阅读
2025-04-25 15:30:58
【活动】分享你的压箱底干货文档,三篇解锁进阶奖励!
墨天轮编辑部
451次阅读
2025-04-17 17:02:24
MySQL 9.3 正式 GA,我却大失所望,新特性亮点与隐忧并存?
JiekeXu
411次阅读
2025-04-15 23:49:58
3月“墨力原创作者计划”获奖名单公布
墨天轮编辑部
368次阅读
2025-04-15 14:48:05
openHalo问世,全球首款基于PostgreSQL兼容MySQL协议的国产开源数据库
严少安
361次阅读
2025-04-07 12:14:29
记录MySQL数据库的一些奇怪的迁移需求!
陈举超
263次阅读
2025-04-15 15:27:53
MySQL 8.0 OCP 1Z0-908 考试解析指南(二)
JiekeXu
242次阅读
2025-04-30 17:37:37
SQL优化 - explain查看SQL执行计划(下)
金同学
227次阅读
2025-05-06 14:40:00
MySQL 8.4 新特性深度解析:功能增强、废弃项与移除项全指南
JiekeXu
220次阅读
2025-04-18 20:21:32
热门文章
0172.K pod日志提示pod has unbound immediate PersistentVolumeClaims解决
2022-05-29 14848浏览
Ubuntu22.04上安装K8s1.24.2--3节点环境安装(一主两从)
2022-07-26 11568浏览
0070.O oceanbase常见错误“ERROR 4012 (HY000) Timeout”处理记录
2021-07-18 11162浏览
0054.C 使用offset explorer 2.1连接kerberos加密kafka
2021-06-15 10242浏览
0180.K kubelet.go 2466 Error getting node not found
2022-07-20 9121浏览