Download and Upload MySql databases with ease π
MySql Cloner is a developer best friend to handle the operations of cloning of MySql databases with a focus on simplicity and minimum requirements.
Despite the existence of more modern ways to sync productions and development MySql databases (databases migrations / databases as a code), more often than not, I find myself in a situation where I need to clone remote MySQL database locally to backup the database schema and user grants, or to quickly spin up a local database for development.
This repo is not a total solution, but a pretty good scaffold that saves you tons of time to achieve a simple objective and to expand from it to other use cases you might require.
Ensure you have the following prerequisites installed:
- Docker (tested on docker v20.10.24)
- Node.js version 16.0.0 or higher (tested on v16.18.0)
Follow these steps to get up and running:
- Install the necessary dependencies
npm install- Create the
.envfile containing the configuration for both the remote and local MySQL
npm run create-envTip: choose a MySql docker image that matches your remote MySql you want to clone to avoid compatibility issues.
Spin up the local instance of MySQL and PHPMyAdmin
docker compose up -dnpm run clone-dbor
npm run clone-db-schema-onlynpm run clone-grantsOnly use if you intend to upload the current local MySQL database in it's current state to another database destination. Bad things can happen if you upload the wrong database to a production server.
This command will explicitly ask you for the local database name to upload AND the remote MySql connection string as a safety measure.
npm run upload-local-dbor
npm run upload-local-db-schema-onlyOnly use if you intend to upload the current local MySQL database user grants to a remote database. Bad things can happen if you upload the wrong grants to a production server.
This command will explicitly ask you for the local users to upload AND the remote MySql connection string as a safety measure.
npm run upload-grantsConnect to any MySql server using phpmyadmin. This can be super useful sometimes for ad-hoc requirements.
npm run launch-arbitrary-phpmyadminnpm run reset-localπ€ DigiDub
If this project has helped you in any way, give it a βοΈ to show your appreciation!
This README was generated with β€οΈ using readme-md-generator