Copying a MySQL database using mysqldump in PHPStorm
Published At: 2025-05-24 22:21:37 UTC
Copying a MySQL database using mysqldump in PHPStorm
In this example we will be using MySQL version 8.x,
the same methods apply to 5.7.x
we will also be using docker.
Download the MySQL zip file of the correct version:
https://dev.mysql.com/downloads/mysql/
if you are using an older version, go to:
https://downloads.mysql.com/archives/community/
And extract to a reasonable location, such as H:\Programs\Mysql\8.3
docker-compose.yml
version: '3'
networks:
BRIDGE:
services:
mysql:
image: mysql:latest
container_name: MYSQL
volumes:
- ./docker/database:/var/lib/mysql:rw
ports:
- "3306:3306"
environment:
- MYSQL_ROOT_PASSWORD=root_password
networks:
- BRIDGE
Run
docker-compose up

Make sure you have both databases available in your database tab in PHPStorm (the one you want to copy from and the one you want to copy to)


Right click on the one you want to copy from, hover over Import/Export
and then click Export with mysqldump
:

Configure the dump in the following way:

Path to mysqldump: the location that the mysql zip file was extracted to, in the bin folder.
Out path: <dump location>\{data_source}-{database}-{timestamp}.mysqldump
at the end of the command string generated add the option --set-gtid-purged=OFF
if the importing user does not have SUPER
privileges
Then click Run:

This will generate a file as defined:

To restore right-click on the one you want to copy to, hover over Import/Export
and then click Restore with 'mysql'
:

Apply settings as before:

Run
