Importing a database over SSH can be a great way to handle large SQL files or to automate database management tasks. In the Aviums Host environment, you can use SSH to connect to your server and use the MySQL command line to import your database. Here’s a step-by-step guide on how to do this:
How to Import a Database Over SSH in Aviums Host
Step 1: Prepare Your SQL File
- Locate Your SQL File: Ensure you have your
.sql
file ready for import. This file should be accessible on your local machine or uploaded to your server via SFTP. - Upload the File: If the file is on your local machine, use an SFTP client (like FileZilla) to upload it to your Aviums Host server. Note the path where you upload it.
Step 2: Access Your Server via SSH
- Open Terminal (or Command Prompt): On your local machine, open a terminal (Linux/Mac) or Command Prompt (Windows).
- Connect to Your Server: Use the SSH command to connect to your server. Replace
username
with your actual username andhostname
with your domain or IP address. - Enter Password: If prompted, enter your password to establish the SSH connection.
Step 3: Navigate to the Directory (Optional)
- Change Directory: If you uploaded your SQL file to a specific directory, navigate to that directory using the
cd
command.
Step 4: Import the Database
-
Use MySQL Command: To import your SQL file, use the following command. Replace
database_name
with the name of the database you want to import into, andfile.sql
with the name of your SQL file.-u database_username
: Your MySQL username.-p
: This option will prompt you to enter your MySQL password.database_name
: The name of the database where you want to import the data.< file.sql
: This tells MySQL to import the data from the specified SQL file.
-
Enter MySQL Password: When prompted, enter your MySQL password.
Step 5: Verify Import Completion
- Check for Errors: If there are no error messages, the import was likely successful.
- Log into MySQL: You can log into MySQL to check if the tables and data have been imported correctly:
- Show Databases: Use the following command to list databases and ensure your data is present:
- Select the Database: Use the
USE
command to switch to your database: - Show Tables: To verify the tables were imported, you can use: