我已经尝试了以下链接给出的所有解决方案:
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/