Restoring and importing a database to your database server

Objective

Following an error on your database, you must be able to restore a backup or import a local database.

Find out how to restore and import your database on your database server.

Requirements


OVHcloud Control Panel Access

  • Direct link: Web Cloud Databases
  • Navigation path: Web Cloud > Web Cloud Databases > Select your database service

Instructions

Info

Web Cloud Databases solutions do not give access to the database management system, but to the databases hosted on it.

  • There is no superuser "root" access.
  • Generic SQL commands work normally, and software such as HeidiSQL, SQuirreL SQL or Adminer is fully compatible.

Restoring and importing a database from the Control Panel

Restoring an existing backup

Click on the tabs below to view each of the 4 steps.

Step 1
Step 2
Step 3
Step 4

Go to the Web Cloud Databases page, then select the solution concerned.

Web Cloud Databases

Importing a local backup

Click on the tabs below to view each of the 4 steps.

Step 1
Step 2
Step 3
Step 4

Go to the Web Cloud Databases page, then select the solution concerned.

Web Cloud Databases

Importing a database outside the Control Panel

In some cases, the RAM available on your database server may not be sufficient to perform the desired import outside the Control Panel. If so, we recommend using the OVHcloud tool in the Control Panel. Refer to the section "Restoring and importing a database from the Control Panel" of this guide.

Click on the import method of your choice to view the content.

Importing a MySQL or MariaDB database from phpMyAdmin

To import your database directly from phpMyAdmin, you must first log in by following the section "Connecting to a MySQL or MariaDB database".

Once logged in to phpMyAdmin, select your database by clicking on its name.

Then click on the Import tab.

Select your backup file by clicking Browse (the file cannot exceed 100 MB).

Info

We recommend splitting your database into several files if it exceeds 100 MB, and performing multiple imports from phpMyAdmin. You can import files larger than 100 MB from the Control Panel by following the step "Restoring and importing a database from the Control Panel".

Leave the default options and click Run to start the import.

Web Cloud Databases
Importing a MySQL or MariaDB database from the command line

This action is only possible via SSH from an OVHcloud shared hosting plan.

cat database_name.sql | mysql --host=server --user=username --port=port --password=password database_name
Importing a MySQL or MariaDB database from a PHP file
1. <?php
2. echo "Your database is being restored.......<br/>";
3. system("cat database_name.sql | mysql --host=server --user=username --port=port --password=password database_name");
4. echo "Completed. Your database is in place on this hosting plan.";
5. ?>
Warning
  • To prevent someone from accessing this file containing sensitive data, secure access to it by following the guide: How do I password-protect a directory?
  • This action is only possible from an OVHcloud shared hosting plan.
Importing a PostgreSQL database from the command line

This action is only possible via SSH from an OVHcloud shared hosting plan in stable version or higher.

psql --host=server --port=port --user=username --password=password database_name < database_name.sql
Importing a PostgreSQL database from a PHP file
1. <?php
2. echo "Your database is being restored.......<br/>";
3. system("PGPASSWORD=password psql --host=server --port=port --user=username --password=password database_name < database_name.sql");
4. echo "Completed. Your database is in place on this hosting plan.";
5. ?>
Warning
  • To prevent someone from accessing this file containing sensitive data, secure access to it by following the guide: How do I password-protect a directory?
  • This action is only possible from an OVHcloud shared hosting plan.

Go further

For specialised services (SEO, development, etc.), contact OVHcloud partners.

If you would like assistance using and configuring your OVHcloud solutions, please refer to our support offers.

Join our community of users.

Was this page helpful?