Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setup password for H2

Tags:

passwords

h2

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.

like image 898
Aubergine Avatar asked May 30 '12 00:05

Aubergine


People also ask

How do I create a username and password for H2?

For example, H2database . new_user_name is the new user name to be created. new_password is password for the new user. existing_user is the existing user name.

How do I connect to my existing H2 database?

Accessing the H2 Console H2 database has an embedded GUI console for browsing the contents of a database and running SQL queries. By default, the H2 console is not enabled in Spring. Then, after starting the application, we can navigate to http://localhost:8080/h2-console, which will present us with a login page.


1 Answers

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.

like image 56
Aubergine Avatar answered Sep 20 '22 15:09

Aubergine