---
title: How to import/export a database on Control Web Panel (CWP)
description: "In **CWP (CentOS Web Panel)**, importing and exporting MySQL/MariaDB databases is a crucial task for backing up, restoring, or migrating databases. This guide will show you how to perform both import and export operations on your databases in CWP using…"
url: "https://truehost.com/support/knowledge-base/how-to-import-export-a-database-on-control-web-panel-cwp/"
updated: "2024-10-07"
category: Cloud servers in Kenya
---

# How to import/export a database on Control Web Panel (CWP)

In **CWP (CentOS Web Panel)**, importing and exporting MySQL/MariaDB databases is a crucial task for backing up, restoring, or migrating databases.

This guide will show you how to perform both import and export operations on your databases in CWP using **phpMyAdmin** or the command line.

### Prerequisites:

- **CWP installed** on your server.
- **Root access** to CWP or access to the specific user account.
- A database already created in CWP (for import operations).

### **Method 1: Using phpMyAdmin**

phpMyAdmin is a graphical tool that allows you to manage your databases easily. You can use it to both import and export databases.

##### **Step 1: Log in to CWP Admin Panel** using **[these](https://truehost.com/support/knowledge-base/how-to-access-cwp-main-whm-panel/)** steps

##### **Step 2: Open phpMyAdmin**

- On the left-hand sidebar, navigate to **SQL Services**.
- Click on **phpMyAdmin**. This will open a new tab with the phpMyAdmin login page.
- Log in using the **database username** and **password** of the database you want to work on.
- When using CWP Admin, it could log you in to phpMyAdmin automatically and you will see all databases on that server. Click on the database that you want to work on.

![](https://truehost.com/support/wp-content/uploads/2024/10/image-135.png)

##### **Step 3a: Export a Database**

- Once logged in, select the database you wish to export from the left-hand panel.
- Click on the **Export** tab at the top
- In the **Export Method** section, choose between:
  - **Quick**: Export with minimal options.
  - **Custom**:Allows you to customize the export settings (e.g., specific tables, format).
- Choose the **SQL** format for the export file. The default is usually just fine
- Click **Go** to download the SQL dump of the database to your local machine.

![](https://truehost.com/support/wp-content/uploads/2024/10/image-136-1024x499.png)

##### **Step 3b: Import a Database**

- If you need to import a database, select the target database from the left panel, or **[create one](https://truehost.com/support/knowledge-base/how-to-create-a-database-in-control-web-panel-cwp/)** if it doesn’t already exist.
- Click on the **Import** tab at the top.
- Under the **File to Import** section, click **Choose File** to select the `.sql` file from your local machine.
- After selecting the file, scroll down and click **Go** to start the import process.

![](https://truehost.com/support/wp-content/uploads/2024/10/image-137-1024x534.png)

- Once the import is complete, you should see a success message.

![](https://truehost.com/support/wp-content/uploads/2024/10/image-138-1024x231.png)

### **Method 2: Using the Command Line**

If you prefer working with the command line or need to import/export larger databases, you can do so via SSH.

##### **Step 1: Log in via SSH** using [these steps](https://truehost.com/support/knowledge-base/how-to-access-a-server-via-ssh-terminal/)

##### **Step 2a: Export a Database via Command Line**

- Run the following command to export the database to an SQL file:
  - Replace `dbuser` with your database username.
  - Replace `dbname` with your database name.
  - Replace `/path/to/backup.sql` with the desired path and file name to save the backup.

```
mysqldump -u dbuser -p dbname > /path/to/backup.sql
```

- Enter the database password when prompted.
- This will create a `.sql` dump file at the specified location.
- You can also bypass the **-u dbuser -p** when using root SSH as follows

```
mysqldump dbname > /path/to/backup.sql
```

When you check the specified location, like /home as I did in the image, you will see your .sql file

![](https://truehost.com/support/wp-content/uploads/2024/10/image-140.png)

##### **Step 2b: Import a Database via Command Line**

- To import a database first uplaod the database dump file (the .sql file) to a location on your server.
- Then use the following command to import the database:
  - Replace `dbuser` with your database username.
  - Replace `dbname` with your database name (ensure it already exists).
  - Replace `/path/to/backup.sql` with the path to the `.sql` file you want to import.

```
mysql -u dbuser -p dbname < /path/to/backup.sql
```

- You can also bypass the **-u dbuser -p** when using root SSH as follows

```
mysql dbname < /path/to/backup.sql
```

I have a .sql file called **truehost_demodb.sql**which is located in**/home** folder of my server. I want to import it to a database called **truehost_demodb1**. Below wil be my command

```
mysql truehost_demodb1 < /home/truehost_demodb.sql
```

![](https://truehost.com/support/wp-content/uploads/2024/10/image-141.png)
