Skip to main content

Create a dump file

If this is running on your local machine, do this. 

/usr/bin/mysqldump -u [USERNAME] --password=[PASSWORD] [DATABASE_NAME] > [BACKUP_FILE.sql]

If it is running in a container, you will need to run this command in that container. 

docker exec [CONTAINER_NAME_OR_ID] /usr/bin/mysqldump -u [USERNAME] --password=[PASSWORD] [DATABASE_NAME] > [BACKUP_FILE.sql]

Replace:

  • [CONTAINER_NAME_OR_ID] with the name or ID of the Docker container running MySQL
  • [USERNAME] with the MySQL username
  • [PASSWORD] with the MySQL user's password
  • [DATABASE_NAME] with the name of the database to dump
  • [BACKUP_FILE.sql] with the desired name for the SQL backup file
Note:

The typical process of creating a database dump requires connecting to the running database server and executing a command like mysqldump or pg_dump to export the database data to a SQL file. However, without a running database instance, these commands cannot be executed.