Java H2 Database - set admin password during startup of the server

Viewed 4847

By default the admin password of the H2 DB is empty. I like to know if there exists a way that the password can be set by default during startup of the server already to an initial value?

I have seen an option called "-webAdminPassword" (java -cp h2-1.4.199.jar org.h2.tools.Server -?) but I guess this is something else. Any other option than executing a SQL script " ALTER USER SA SET PASSWORD 'sa' " after the startup?

Thank you

1 Answers

There is no default password or default admin username in H2. If you have a permission to create a new database (for example, you always have such permission when an embedded database is used) the username and password that you specify during the first connection are used in the new database to create an user with ADMIN rights.

https://h2database.com/html/tutorial.html#creating_new_databases

Related