wp-cli / ideas

💡 Ideas and feature requests are collected here
40 stars 1 forks source link

Add --prefix=<prefix> option to wp db create #151

Closed ponasromas closed 1 year ago

ponasromas commented 3 years ago

Feature Request

Please add option to wp db create command to set custom database table prefix.

wp db create --dbuser=<value> --dbpass=<value> --prefix=<prefix[optional]>

Thank you.

erickhavel commented 3 years ago

I haven't really used wp db create so I might be missing something but shouldn't it take the value from wp-config.php? What use case do you have for using a custom one?

ponasromas commented 3 years ago

Yes, this value is set in wp-config.php. use case would be to increase resistance for SQL injection by randomizing db prefix. Security via obscurity.

Another use case would be multiple WP installations on the same database.

erickhavel commented 3 years ago

Looks like you could this to change the prefix after creating the DB: https://github.com/iandunn/wp-cli-rename-db-prefix (changing it both in DB and wp-config.php)

danielbachhuber commented 1 year ago

The database prefix is defined in wp-config.php and can be configured when running wp config create.

The database doesn't really know of WordPress' database prefix.