zoukankan      html  css  js  c++  java
  • 导入sql文件到mysql容器中

    导入sql文件到mysql容器中

     1. 在docker-compose文件中增加挂载路径./sqlfile,将sql文件映射进容器。

        volumes:

          - ./data/docker/mysql:/var/lib/mysql

          - ./mysql/:/docker-entrypoint-initdb.d/

          - ./conf/mysqld.cnf:/etc/mysql/mysql.conf.d/mysqld.cnf

          - ./sqlfile:/app/sqlfile

      或者可以使用docker cp 的方式。

    2. 进入容器内部,导入sql文件到指定数据库。

    $ docker exec -it 54e61c8c4846 bash

    #mysql -uroot -proot

    mysql> show databases;

    +--------------------+

    | Database           |

    +--------------------+

    | information_schema |

    | apigateway-ai      |

    | mysql              |

    | performance_schema |

    | sys                |

    +--------------------+

    5 rows in set (0.00 sec)

    mysql> use apigateway-ai;

    mysql> source /app/sqlfile/ai_api_profile.sql;

    mysql> show tables;

    +-------------------------+

    | Tables_in_apigateway-ai |

    +-------------------------+

    | ai_api_profile          |

    +-------------------------+

    1 row in set (0.00 sec)

    结束。

  • 相关阅读:
    CF1132G
    CF1129B
    CF1131G
    CF1109D
    CF1110H
    CF1106F
    my.cnf 配置
    mysql 导入导出
    mysql 批量删除表数据
    国内开源镜像站
  • 原文地址:https://www.cnblogs.com/liusingbon/p/12842903.html
Copyright © 2011-2022 走看看