Admin rights issue

35 views
Skip to first unread message

pr1

unread,
Sep 29, 2019, 4:34:22 AM9/29/19
to H2 Database
Hello,

In a Spring Boot project, I have defined an H2 Scope.

My schema-h2.sql script contains the following code:

CREATE SCHEMA IF NOT EXISTS ABC_SCHEMA AUTHORIZATION xyz
;


SET SCHEMA
= ABC_SCHEMA;



Unfortunately, when I "install" my Java project, I get the following error message:

Admin rights are required for this operation; SQL statement:
CREATE SCHEMA IF NOT EXISTS ABC_SCHEMA AUTHORIZATION xyz
[90040-199]


Does anyone know how make the schema-h2.sql script run in admin mode?

Many thanks.

Best regards,

pr1





Evgenij Ryazanov

unread,
Sep 29, 2019, 5:39:35 AM9/29/19
to H2 Database
Hello.

When you created this database a user with ADMIN rights were created using the user name and password that were specified to create a first connection. You need to use its user name and password to connect to the database.

After it you can either execute this script under that account or give ADMIN privileges to your current user using ALTER USER userName ADMIN TRUE

If you lost the credentials of your initial ADMIN user you can't do anything from the SQL. You need to use the recovery tool.

pr1

unread,
Sep 29, 2019, 6:04:17 AM9/29/19
to H2 Database
Hi Evgenij.

I've added an ALTER USER statement to my script, and it now works fine.

Many thanks.

Cheers,

pr1


CREATE USER IF NOT EXISTS us1 PASSWORD 'us1';

ALTER USER us1 ADMIN TRUE
;

CREATE SCHEMA IF NOT EXISTS MY_SCHEMA AUTHORIZATION us1
;

SET SCHEMA
= MY_SCHEMA;

CREATE TABLE table1
(

...


Reply all
Reply to author
Forward
0 new messages