Setup password for H2

2020-07-06 03:26发布

问题:

How to set up my own password for accessing the h2 while working in embedded mode?

(if anyone confused - talking about the root password for accessing the database)

In Eclipse it seems that password assignment occurs at the moment of db connection creation which in turn launches the process of schema creation, where we provide username and password.

Even if this is true how to change existing password after set up? I've searched in information schema - found `users', there is no password column though.

The process seems to be really weird, what am I missing. In PostgreSQL it is a way easier.

So the questions are:

  1. The passwords are assigned upon new schema creation?

  2. How to change the password for current user?

I suspect it is done via the query, I believe it will have specific syntax, if that is the case I would appreciate sample query too, as I am not yet famillar with this SQL implementation.

回答1:

Oh I guess life is not that bad :-).

Found on:

http://www.h2database.com/html/grammar.html#alter_user_set_password

To change it we obviously have to be able to connect to database(know username and password), as I said these are the ones we use during connection set up.

Then create simillar sql snippet ALTER USER admin SET PASSWORD 'superPw';

I personally believe these high level operations have to be allowed to be done in wizards. Hope this helps.



标签: passwords h2