Wp-cli: wp db import documentation questions

Created on 17 Jun 2016  路  3Comments  路  Source: wp-cli/wp-cli

I went to use wp db import the other day, but was a little unsure of how it worked. If you can answer the following questions I'll update the docs on it:

  1. Will it automatically create a database with the name of the database in wp-config.php, or should the database already be created?
  2. Does it empty the existing database? If not, does it overwrite entries with common IDs in the existing database or does it work more like the WP importer, creating additional rows?
db documentation

Most helpful comment

@ernilambar is correct. It doesn't create the database, and it only performs whatever tasks are defined in your sql file. If your sql file has queries to empty the database (or drop tables), then it would empty the database. Or, if your sql file just has INSERT queries, then it will just insert new data into the database.

All 3 comments

AFAIK, database should already exist for db import. And it should be as per DB_NAME in wp-config.php.
It does not empty database. It just executes queries those are in the sql file.

@ernilambar is correct. It doesn't create the database, and it only performs whatever tasks are defined in your sql file. If your sql file has queries to empty the database (or drop tables), then it would empty the database. Or, if your sql file just has INSERT queries, then it will just insert new data into the database.

@danielbachhuber May be we can close this now.

Was this page helpful?
0 / 5 - 0 ratings