MySQL is a relational database management system based on SQL – Structured Query Language. The most common use for MySQL however, is for the purpose of a web database.
We don’t really want to send the MySQL database to GitHub, even a private repository.
For this reason, we will add remote access to your MySQL server.
1. Find your IP Address and add Remote Access Host to SiteGround
We will set up a remote connection to export and import (dump) databases from/to our server-based on our IP address.
Before anything else, we need to find what’s our IP Address.
Then, we need to go to SiteGround Control Panel Site > MySQL
and click on the Remote tab.
This is where we add and save our IP Addresses to the server.
2. Find database access credentials
Next, we need to gather some information from our SiteGround Control Panel.
Find Site IP Address, Database Name, Database User & Password. You probably need to write these down before moving on to the next step.
Note: Most of these are located on Dashboard
and Site > MySQL
pages.
3. Export MySQL database with mysqldump.exe
Open Command Prompt on your local machine and run the following sequence of commands:
C:\Users\username> cd C:\Users\username\Dropbox\GitHub\domain\ C:\Users\username\Dropbox\GitHub\domain\> mkdir db_backups C:\Users\username\Dropbox\GitHub\domain\> cd db_backups C:\Users\username\Dropbox\GitHub\domain\> C:\Xampp\mysql\bin\mysqldump.exe -h 1.1.1.1 -u username -p database_name > database_2020-01-12.sql Enter password: ********
Note: Replace the placeholder text with the ones you found at SiteGround.
The above will create a new directory locally for backups db_backups
and export the database from your server.
Having your database files in C:\Users\username\Dropbox\GitHub\
will also sync them to your Dropbox.