<small id='buYyk'></small><noframes id='buYyk'>

    • <bdo id='buYyk'></bdo><ul id='buYyk'></ul>
      <tfoot id='buYyk'></tfoot>
      <i id='buYyk'><tr id='buYyk'><dt id='buYyk'><q id='buYyk'><span id='buYyk'><b id='buYyk'><form id='buYyk'><ins id='buYyk'></ins><ul id='buYyk'></ul><sub id='buYyk'></sub></form><legend id='buYyk'></legend><bdo id='buYyk'><pre id='buYyk'><center id='buYyk'></center></pre></bdo></b><th id='buYyk'></th></span></q></dt></tr></i><div id='buYyk'><tfoot id='buYyk'></tfoot><dl id='buYyk'><fieldset id='buYyk'></fieldset></dl></div>

      <legend id='buYyk'><style id='buYyk'><dir id='buYyk'><q id='buYyk'></q></dir></style></legend>
      1. 在 Kubernetes 上创建时如何初始化 mysql 容器?

        时间:2023-09-18
          <tbody id='aeLiQ'></tbody>

          <i id='aeLiQ'><tr id='aeLiQ'><dt id='aeLiQ'><q id='aeLiQ'><span id='aeLiQ'><b id='aeLiQ'><form id='aeLiQ'><ins id='aeLiQ'></ins><ul id='aeLiQ'></ul><sub id='aeLiQ'></sub></form><legend id='aeLiQ'></legend><bdo id='aeLiQ'><pre id='aeLiQ'><center id='aeLiQ'></center></pre></bdo></b><th id='aeLiQ'></th></span></q></dt></tr></i><div id='aeLiQ'><tfoot id='aeLiQ'></tfoot><dl id='aeLiQ'><fieldset id='aeLiQ'></fieldset></dl></div>
            <bdo id='aeLiQ'></bdo><ul id='aeLiQ'></ul>

                <small id='aeLiQ'></small><noframes id='aeLiQ'>

              1. <tfoot id='aeLiQ'></tfoot>

                  <legend id='aeLiQ'><style id='aeLiQ'><dir id='aeLiQ'><q id='aeLiQ'></q></dir></style></legend>
                  本文介绍了在 Kubernetes 上创建时如何初始化 mysql 容器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想在容器的 MySQL 上设置初始数据.在docker-compose.yml中,这样的代码可以在运行容器时创建初始数据.

                  I want to set initial data on MySQL of container. In docker-compose.yml, such code can create initial data when running container.

                  volumes:
                    - db:/var/lib/mysql
                    - "./docker/mysql/conf.d:/etc/mysql/conf.d"
                    - "./docker/mysql/init.d:/docker-entrypoint-initdb.d"
                  

                  但是,如何在运行时在 Kubernetes 上创建初始数据?

                  However, how can I create initial data on Kubernetes when running?

                  推荐答案

                  根据 MySQL Docker 镜像 README,与容器启动时数据初始化相关的部分是确保您所有的初始化文件都挂载到容器的/docker-entrypoint-initdb.d文件夹中.

                  According to the MySQL Docker image README, the part that is relevant to data initialization on container start-up is to ensure all your initialization files are mount to the container's /docker-entrypoint-initdb.d folder.

                  您可以在 ConfigMap 中定义您的初始数据,并像这样在您的 pod 中挂载相应的卷:

                  You can define your initial data in a ConfigMap, and mount the corresponding volume in your pod like this:

                  apiVersion: v1
                  kind: Pod
                  metadata:
                    name: mysql
                  spec:
                    containers:
                    - name: mysql
                      image: mysql        
                      ports:
                        - containerPort: 3306
                      volumeMounts:
                        - name: mysql-initdb
                          mountPath: /docker-entrypoint-initdb.d
                    volumes:
                      - name: mysql-initdb
                        configMap:
                          name: mysql-initdb-config
                  ---
                  apiVersion: v1
                  kind: ConfigMap
                  metadata:
                    name: mysql-initdb-config
                  data:
                    initdb.sql: |
                      CREATE TABLE friends (id INT, name VARCHAR(256), age INT, gender VARCHAR(3));
                      INSERT INTO friends VALUES (1, 'John Smith', 32, 'm');
                      INSERT INTO friends VALUES (2, 'Lilian Worksmith', 29, 'f');
                      INSERT INTO friends VALUES (3, 'Michael Rupert', 27, 'm');
                  

                  这篇关于在 Kubernetes 上创建时如何初始化 mysql 容器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:连接到 docker-compose mysql 容器拒绝访问,但运行相同图像的 docker 不会 下一篇:如何在 SQL Server 2005 中将多行组合成逗号分隔的列表?

                  相关文章

                  • <bdo id='Rz8a6'></bdo><ul id='Rz8a6'></ul>

                      <i id='Rz8a6'><tr id='Rz8a6'><dt id='Rz8a6'><q id='Rz8a6'><span id='Rz8a6'><b id='Rz8a6'><form id='Rz8a6'><ins id='Rz8a6'></ins><ul id='Rz8a6'></ul><sub id='Rz8a6'></sub></form><legend id='Rz8a6'></legend><bdo id='Rz8a6'><pre id='Rz8a6'><center id='Rz8a6'></center></pre></bdo></b><th id='Rz8a6'></th></span></q></dt></tr></i><div id='Rz8a6'><tfoot id='Rz8a6'></tfoot><dl id='Rz8a6'><fieldset id='Rz8a6'></fieldset></dl></div>
                      <legend id='Rz8a6'><style id='Rz8a6'><dir id='Rz8a6'><q id='Rz8a6'></q></dir></style></legend>

                      <small id='Rz8a6'></small><noframes id='Rz8a6'>

                    1. <tfoot id='Rz8a6'></tfoot>