How to Import a Database Over SSH


Step 1 - Preparations

  • Upload the database to your website's public_html folder – you can do it via FTP or with the File Manager

  • Create a new database or clear the one you plan to import into

  • If you are unsure about the value of your database password, change it

Step 2 - Connecting via SSH

  • Connect to your hosting account via SSH

  • Open your root directory (public_html)

  • If the database backup file is displayed – go to the next step

  • If you do not see the backup file, double-check using the File Manager that the file is indeed uploaded and placed in the public_html folder

The parameters of your database are:

  • MySQL Database name: u123456789_database
  • MySQL Username: u123456789_admin
  • Uploaded database file: database.sql
  • Path to your .sql file: /home/mydomain.com/public_html/websitedump.sql

How to reache to website files with ssh in cyberpanel

$ cd /home/mydomain.com/public_html

## compress folder with ssh

$ apt install zip

$
zip -r wp-content.zip wp-content

## extract folder with ss $ unzip wp-content.zip

## import databse via ssh

$ mysql -u username -p domain_db1 < /home/mydomain.com/public_html/websitedump.sql

OR
$ mysql -u root mysql> use domain_db1 mysql> source /home/mydomain.com/public_html/websitedump.sql;

## export database via ssh $ mysqldump -u root -p domain_db1 > websitedump.sql

## export multiple databases $ mysqldump -u root -p ---databases domain_db1 domain_db2 domain_db3 > fullwebsitedump.sql


Ref: https://community.cyberpanel.net/t/how-to-access-cyberpanel-website-files-and-import-export-db-dumps-using-ssh/40923

Did you find this article useful?