Exporting a database over SSH is an efficient way to back up your data or migrate your database to another server. In the Aviums Host environment, you can connect to your server via SSH and use the mysqldump
command to export your database. Here’s a step-by-step guide on how to do this:
Step 1: Prepare Your Environment
- Open Terminal or Command Prompt: On your local machine, open a terminal (Linux/Mac) or Command Prompt (Windows).
- Install SSH Client: Ensure you have an SSH client installed. Most Linux and Mac systems come with one by default. For Windows, you might use PuTTY or the built-in SSH command in Windows 10 and later.
Step 2: Connect to Your Server via SSH
- Use SSH Command: Connect to your server by using the following command. Replace
username
with your actual username andhostname
with your domain name or server IP address: - Enter Password: If prompted, enter your password to establish the SSH connection.
Step 3: Export the Database Using mysqldump
-
Run mysqldump Command: Use the
mysqldump
command to export your database. Replacedatabase_name
with the name of your database,username
with your MySQL username, andoutput_file.sql
with the desired name for your exported file:-u username
: Your MySQL username.-p
: This option will prompt you to enter your MySQL password.database_name
: The name of the database you want to export.>
: This symbol directs the output to a file.output_file.sql
: The name of the file where the exported data will be saved.
-
Enter MySQL Password: When prompted, enter your MySQL password.
Step 4: Verify Export Completion
- Check for Errors: If there are no error messages, the export was likely successful.
- List Files: Use the
ls
command to confirm that the export file (output_file.sql
) is created in the current directory: - Download the Exported File: If you need to download the exported file to your local machine, use an SFTP client (like FileZilla) or SCP command:
/path/to/output_file.sql
with the path on the server and/local/path
with the path on your local machine where you want to save the file.
Step 5: Disconnect from SSH
- Exit SSH: Once you’ve finished exporting the database and downloading the file, you can exit the SSH session by typing: