Reputation: 10419
To create a user in H2, one does:
CREATE USER NEWUSER PASSWORD 'P';
How is it possible to create a new user that can connect to an existing database in H2?
I have tried:
GRANT ALL TO NEWUSER;
but this does not work.
Any ideas?
Upvotes: 3
Views: 9413
Reputation: 327
This worked on H2 version 2.1.210:
Create new user with command:
CREATE USER newuser PASSWORD 'newpwd';
Log in as admin (schema owner, by default it's 'sa') and get schema name:
SELECT * FROM INFORMATION_SCHEMA.SCHEMATA;
In my case the schema name was 'PUBLIC';
To assign all rights to the new user, use this command:
GRANT ALL ON SCHEMA PUBLIC TO newuser;
Check the result, you should see newuser with RIGHTS=ALL here:
SELECT * FROM INFORMATION_SCHEMA.RIGHTS;
Upvotes: 0
Reputation: 363
You can do as follows (see here):
create user if not exists scott password 'tiger' admin;
Upvotes: 7
Reputation: 11
You could try setting user as administrator:
ALTER USER TOM ADMIN TRUE
Upvotes: 1