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 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.

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.

Step 3b: Import a Database #
- If you need to import a database, select the target database from the left panel, or create one 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.

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

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 #
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.
- Replace
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

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.
- Replace
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
