mysqldump is a command line tool that can export or backup a database. In order to export the database, you may need to determine which database your site is using. The steps below cover both how to find the correct database as well as how to export it using mysqldump.
Related Articles
Import MySQL Database From Command Line
Export MySQL Database Using phpMyAdmin
SSH into Shared Server
How to SSH into VPS or Dedicated Servers
Find the database for the site
- Log into the cPanel account where the database is located
- In the File Manager, navigate to the site's document root
- Locate the site's configuration file to locate the database name, user, and user password for the specific database
- Locations for configuration files for popular CMS
- Boldgrid/WordPress
- /home/userna5/docroot/wp-config.php
- Prestashop 1.6
- /home/userna5/docroot/config/settings.inc.php
- Prestashop 1.7
- /home/userna5/docroot/app/config/parameters.php
- Drupal
- /home/userna5/docroot/sites/default/settings.php
- Moodle
- /home/userna5/docroot/config.php
- Boldgrid/WordPress
- Locations for configuration files for popular CMS
REPLACE: Replace userna5 with the cPanel username and docroot with the site's document root.
EXAMPLE: The following image shows a sample WordPress configuration file with database settings. In this example, the database name and database user would be imhkmc5_wp412.
Exporting the database
- SSH into the appropriate server
- Run the following command in the terminal:
mysqldump -u $databaseuser -p $mydatabase > /home/userna5/database-MM-DD-YYYY.sql
REPLACE: Update $databaseuser and $mydatabase to the appropriate user and database name, and change userna5 to the cPanel username.
REPLACE: Replace database-MM-DD-YYYY with the name of the database and the appropriate date for the database backup. - Command will prompt for a password; use password from the configuration file from Find the database for the site
NOTE: Depending on the database size, this can take a few minutes.
NOTE: In the command line, typing the password at the prompt will not display the password. - If the command runs without any errors, the database file can be found in the cPanel user's home directory with the name specified earlier
EXAMPLE:
Comments
0 comments
Article is closed for comments.