helm启动单节点mysql

前言

1)本文使用helm启动单节点mysql。
2)生产高可用集群: 《helm启动mysql-ha》
3)其他部署方式:《docker-compose启动mysql》《helm启动单节点mysql》
4))web管理工具推荐 :《k8s启动phpmyadmin》

1. 准备

  • chart包
    从 https://github.com/helm/charts 已下载 charts-master, 其中stable目录里包含mysql目录,该目录即为单机版mysql的chart包

  • 安装文档
    进入上边github地址,找到msyql目录,下边有安装文档和所有可以换变量。

2. 修改变量

mysql/values.yaml 文件包含需要修改的变量

  • 修改root密码
    如果这里不设置,也可以启动Release的时候用命令覆盖。
mysqlRootPassword: YunWeiDao888
  • 修改为 service
    修改service 代理方式为nodeport
service:
annotations: {}
## Specify a service type
## ref: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services---service-types
type: NodePort
#type: ClusterIP
port: 13306
nodePort: 30102
# nodePort: 32000
# loadBalancerIP:
  • 其他根据需要修改

3. 启动Release

# cd charts-master/stable/mysql
# helm install mysql -n mysql --set mysqlRootPassword=YunWeiDao888 ./

说明:如果前边在values.yaml文件中修改了,上边命令可以不加 --set mysqlRootPassword

FAQ

有些镜像版本默认root只能本地用户登录,且不使用密码。

因此需要进入容器不使用密码登录

# kubectl exec -it -n mysql mysql-7f4776db6f-hft2r bash
# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5677
Server version: 5.7.28 MySQL Community Server (GPL)
Copyright (c) 2000, 2019, 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>

创建远程登录账号

mysql> grant all on *.* to root@'%' identified by ' YunWeiDao888';
mysql> flush privilege;

在这里插入图片描述

posted on   运维开发玄德公  阅读(60)  评论(0编辑  收藏  举报  

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示