WP-CLI is a powerful command line utility for WordPress, which is included by default with your hosting plan or server. It can be used to perform many of the actions you would normally complete in the WordPress dashboard, such as installing or updating plugins and themes, managing users, making changes to the site configuration, and much more.
A database file can be easily imported using WP-CLI. Since the WordPress configuration file already has the database credentials, they don't need to be added to the command used for importing.
Related Articles
Export Database Using mysqldump
Export MySQL Database Using phpMyAdmin
SSH into Shared Server
Find the Document Root of a Domain
Import Database
- Access the server via SSH or using the Terminal in cPanel
- Navigate to the site's document root using the cd command
cd public_html
REPLACE: public_html with your domain's document root if different. - Run the following command to import the database
wp db import database.sql
REPLACE: database.sql with the name of the SQL file.
NOTE: As a best security practice, it is recommended to move the SQL file outside of the site's document root. The following command will move the file to the user's home directory (e.g. /home/userna5/).mv database_name.sql ~
REPLACE: database.sql with the name of the SQL file.
TIP: For more information, review the WordPress CLI Documentation.