php - mysql>源backupfile.sql对我不起作用

标签 php mysql docker docker-compose

我已经尝试了以下链接给出的所有解决方案:
Solution link但是我失败了。
我有docker的exec mysql实例

绝对路径mysql> source D:\dc@vsw\XXXX\suranabr_dev01_1.sql错误Failed to open file 'D:\dc@vsw\XXXX\suranabr_dev01_1.sql', error: 2

最佳答案

您为什么不将backupfile.sql放置在dockerfile中,以便一旦容器启动将自动还原它?

FROM mysql
COPY backupfile.sql  /docker-entrypoint-initdb.d/

When a container is started for the first time, a new database with the specified name will be created and initialized with the provided configuration variables. Furthermore, it will execute files with extensions .sh, .sql and .sql.gz that are found in /docker-entrypoint-initdb.d


mysql-docker-Initializing a fresh instance
要么
docker exec -i mysql-container mysql -uuser -ppassword name_db < backup.sql
Import data.sql MySQL Docker Container
或使用docker-compose
version: '3.1'

services:

  db:
    image: mysql
    command: --default-authentication-plugin=mysql_native_password
    restart: always
    volumes:
      - $PWD/backup.sql : /docker-entrypoint-initdb.d/backup.sql
    environment:
      MYSQL_ROOT_PASSWORD: example
      MYSQL_DATABASE: test


关于php - mysql>源backupfile.sql对我不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62947462/

相关文章:

PHP Softlayer 对象存储上传 SSL 错误

php - 2 个使用 PHP 的表单。一种用于添加,一种用于添加更改

sql-server - 在镜像构建时将种子数据添加到基于Docker的Microsoft SQL Server

docker - 如何从 Rancher 的私有(private)网络中暴露 docker 容器?

docker - 如何在谷歌云平台上使用docker bridge网络?

php - 数组到字符串的转换——关联数组

php - 如何安装 Pecl Phar? (得到错误)

mysql - 如何在 SQL 中生成 "column3"= "column1"- "column2"

php - MySql UNION 具有应用默认值的不同列?

php - 我可以在不先选择数据库的情况下使用 Laravel 的 Schema::createDatabase() 吗?