To restore an SQL backup using the terminal on a cPanel server, you'll typically follow these steps:
1. Access the Terminal: Log in to your server via SSH. You can use a terminal client like PuTTY (for Windows) or the terminal on macOS/Linux.
2. Navigate to Your Backup File: Use the `cd` command to navigate to the directory where your SQL backup file is located. For example:
```bash
cd /path/to/your/backup/
```
3. **Log in to MySQL**: You can restore the database using the `mysql` command. Replace `username`, `password`, and `database_name` with your actual MySQL username, password, and the name of the database you want to restore to.
```bash
mysql -u username -p database_name < backup_file.sql
```
After entering this command, you'll be prompted to enter your MySQL password.
4. **Check for Errors**: Once the command has run, check for any errors in the output. If the command completes without errors, your database should be restored successfully.
### Additional Tips:
- **Create the Database**: Make sure the target database exists. If not, create it first:
```bash
mysql -u username -p -e "CREATE DATABASE database_name;"
```
- **Backup Before Restoring**: It’s a good idea to back up your current database before restoring a new one, in case you need to revert:
```bash
mysqldump -u username -p database_name > backup_before_restore.sql
```
If you encounter any issues, be sure to check the MySQL error logs for more detailed information.
