In this manual we will show you how to import a database(MySQL) into your Cloud server using SSH, for example a Cloud SWPanel Smart Web D5. This is useful if the import via phpMyAdmin fails or any other issue when uploading the database.
If you have a Cloud with SWPanel administration panel, it is advisable to previously create a database (or delete the one you plan to import), this must have the same name as the database to import. You can follow the following manual to create a database from SWPanel:
How to create a MySQL or MariaDB database.
In this way, the imported database will be manageable from SWPanel.
info NOTE: If you do not have a Cloud with SWPanel administration panel, you can skip this step. Afterwards you will have to create the database manually.
It is necessary that you have a .sql file which is itself the database to import, when uploading this file to the server you can do it via FTP or SFTP("root"):
The most important thing is to know the directory where you uploaded the database (.sql) inside the server to later import it.
At the time of registering the server, both from the web and from the SWPanel, you will be sent an email to your email account with the access credentials SSH (IP, port, user and password) of your Cloud server for the administrator user ("Root"). With these credentials, you will be able to access your server.
You can refer to the following manual to connect to the server via SSH: Connect to your Cloud via console using PuTTY
You can consult the following manual to connect to the server via Console from SWPanel: How do I access my Cloud using the console through SWPanel
Inside the server, you must make sure that you have the database already created in MySQL:
Access to MySQL
mysql -u root -p
danger The requested password, corresponds to the administrator's password ("root").
After login, you will be able to list the current databases with the following command
show databases;
In the displayed list you will have to confirm if you have the database, in case it does not exist, you will have to create it following point 1 ("Environment preparation") or create it manually with the following command:
create database BBDDSWMANUALES;
Once you have the database in MySQL, you must go to the database directory (.sql file) and you can import the ".sql" file with the following command:
mysql -u root -p BBDDSWMANUALES < BBDDSWMANUALES_BACKUP.sql
danger The requested password, corresponds to the administrator's password("root").
That's all! you now have all the information required to import your MySQL database via SSH.