Importing a database over SSH can be a more efficient method, especially for large databases. Here’s a step-by-step guide to help you do this:
Step 1: Access SSH
- Open Your Terminal:
- Use a terminal application (like Terminal on macOS/Linux or PuTTY on Windows).
- Connect via SSH:
Use the following command to connect to your server:
bash
Copy code
ssh [email protected]
- Replace username with your SSH username and yourserver.com with your server’s IP address or domain name.
- Enter Your Password:
- Enter your password when prompted to log in.
Step 2: Navigate to the Directory
- Locate Your SQL File:
Use the cd command to navigate to the directory where your SQL file is stored. For example:
bash
Copy code
cd /path/to/your/file
Step 3: Import the Database
- Use the MySQL Command:
To import the database, use the following command:
bash
Copy code
mysql -u database_user -p database_name < filename.sql
- Replace database_user with your MySQL username, database_name with the name of the database you want to import into, and filename.sql with the name of your SQL file.
- Enter the MySQL Password:
- You will be prompted to enter the password for the MySQL user. Enter it to proceed with the import.
Step 4: Verify the Import
- Check for Errors:
- After the import process, watch for any error messages in the terminal. If the command completes without errors, your database has been imported successfully.
- Log into phpMyAdmin (Optional):
- To confirm that the data has been imported correctly, you can log into phpMyAdmin through cPanel and check the tables in your database.
Conclusion
Importing a database over SSH in cPanel can be a quick and efficient way to handle large files. By following these steps, you can ensure a successful import. Always remember to back up your existing database before performing imports to prevent data loss!
