Before starting, it is important to mention that not all hosting plans provide SSH access. To follow this guide, you will need a plan that includes this feature. The available plans are the Senior plans or higher. You can check our comparison table of plans to find the option that best suits your needs.
Note: The testing platform includes SSH access, but this plan does not allow the activation of external database access, which is required to import a database via SSH.
Prerequisites
- Make sure that SSH access is enabled on your hosting plan. If you need help enabling and accessing SSH, you can follow our support guide.
Uploading the SQL File
Before importing your database, you must upload the .sql file (the database) to your hosting. We recommend using an FTP manager such as FileZilla for this.
Once you access the hosting via FTP, make sure to upload your .sql file to the /entrada folder of your server via FTP.
SSH Connection and Import Commands
Once the file has been uploaded, you can connect to the hosting via SSH. You can obtain the access details from your control panel.
The first step is to establish the connection to the hosting. To do so, you will need the SSH user of your hosting and the server IP. Once entered, the system will ask for the password assigned when SSH access was activated.
Example screenshot of SSH access:
After connecting via SSH, you can run the command ls -la. This command will display a list of the files and folders detected, where you should see the .sql file that you uploaded.
Example screenshot of a listed .sql file:
Next, it is time to start importing the .sql file. Use the following command to import your database:
mysql -u su_usuario_mysql -p -h IP_de_su_alojamiento Nombre_de_su_base_de_datos < archivo_bbdd.sql
You must replace the data marked in bold in the command with the corresponding information. You will need the connection details of the MySQL user and the database where you want to import it: Where to see the MySQL connection details
Example screenshot of executing a .sql file via SSH:
The import may take some time, during which the terminal will not display new lines until the process has finished.