Bench command with --force option

Hi All,

I’m using bench command with --force option to create a site with existing database. But the command makes new database and user. Maybe I’m doing this all wrong. I did create a site with this command before on older version of bench without any issues. Maybe how to use the options is different on new version? I’m using bench version 4.1.0. Here is the command I’m trying.

bench new-site erpdemo --db-name erpdemo --mariadb-root-username root --mariadb-root-password password --install-app erpnext --verbose --force
Created user b1d50388e84850b5 <— creates this user and not erpdemo
Created database b1d50388e84850b5 <— creates this database instead of using existing erpdemo
Granted privileges to user b1d50388e84850b5 and database b1d50388e84850b5
Starting database import…
Imported from database /home/frappe/frappe-bench/apps/frappe/frappe/data/Framework.sql
Installing frappe…
Updating frappe : [========================================]
Updating country info : [========================================]
Set Administrator password:
Re-enter Administrator password:
Installing fixtures…
Installing erpnext…
Updating erpnext : [========================================]
Installing fixtures…
*** Scheduler is disabled ***

If you have an existing database you have to use bench restore

Edit: you will need a dump for that

Thanks for the reply. I was puzzled as to why using -db-name option did not create a database with the name I specified. I tried few more times using -db-name option but the bench new-site command still creates database with random database name like the one I pointed out in my earlier post.

I was able to set the database name up the way I wanted by renaming the database name in Mariadb after bench new-site command creates the database, then edit the site_config.json file in my site to match the database, and restore back the data. So there is a way around to accomplish what I want. I just can’t do this using -db-name option.

Thanks,
GR

1 Like

@graybuck

Bench new-site does not have a switch --db-name to create the database with canonical name. But this can be an excellent addition to the tool.

Can you please raise an issue on Bench Issues?

Thanks for reporting the issue.

Are you sure? I got the option from the bench command cheat sheet. Here is the URL
https://frappe.github.io/frappe/user/en/bench/resources/bench-commands-cheatsheet.html

Maybe the option is no longer supported?

Thanks,GR