Createdb: database creation failed: ERROR: role "<username>" does not exist
search cancel

Createdb: database creation failed: ERROR: role "<username>" does not exist


Article ID: 108030


Updated On:


CA Application Performance Management Agent (APM / Wily / Introscope) INTROSCOPE


During an upgrade from to, I've manually installed the PostgreSQL 9.6.2 using the script in
 /<em_home>/install/database-install/linux. When I tried to restore the <database_name> backup copy, it failed with the following error:

[apmadmin unix]$ ./ localhost /apmdb/PostgreSQL-9.6.2/ postgres  <db name> <username> <password> 5432 /apmdb/dbbackup/cemdb.backup

createdb: database creation failed: ERROR: role "<role_name>" does not exist
Restoring the database data. The restore may take a long time depending on the size of the backup file.
pg_restore: invalid option -- 'i'
Try "pg_restore --help" for more information.
Upgrading the database

[INFO] [main] [root] [UpgradeSchema] - DBDetails: hostName: <host> port: 5432 databaseName:<database_name> user: <user>

[INFO] [main] [root] [UpgradeSchema] - DBType: postgres
[INFO] [main] [root] [UpgradeSchema] - Desired Version:
[INFO] [main] [root] [UpgradeSchema] - Scripts location: ../
[INFO] [main] [root] [UpgradeSchema] - Postgres installation directory: /apmdb/PostgreSQL-9.6.2/
[ERROR] [main] [root] [UpgradeSchema] - FATAL: password authentication failed for user "<user>"
org.postgresql.util.PSQLException: FATAL: password authentication failed for user "<user>"

at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(
at org.postgresql.core.ConnectionFactory.openConnection(
at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(
at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(
at org.postgresql.jdbc3g.AbstractJdbc3gConnection.<init>(
at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(
at org.postgresql.jdbc4.Jdbc4Connection.<init>(
at org.postgresql.Driver.makeConnection(
at org.postgresql.Driver.connect(
at java.sql.DriverManager.getConnection(
at java.sql.DriverManager.getConnection(
at com.wily.apm.dbutil.SqlExecutor.getConnection(
at com.wily.apm.dbtools.upgradeschema.UpgradeSchema.upgradeSchema(
at com.wily.apm.dbtools.upgradeschema.UpgradeSchema.main(

[ERROR] [main] [root] [UpgradeSchema] - Error creating schema
psql.bin: FATAL: database "<database_name>" does not exist
Database restoration is done



CA Application Performance Management


User "<username>" required to run the restore script, was not created by the script.


The normal and recommended practice is to use the EM installer to install the PostgreSQL, which it will create the user "admin" along with the cemdb instance.

To work around the issue in this case, you can manually create the user "admin" using PgAdmin > PostgreSQL-9.6.2 > Login Roles.
The user admin does not require SuperUser privilege, the default privilege is sufficient.

Once the user is manually created, re-run the restore command again.

Additional Information

Login/Group Role Dialog
Install and Configure the APM Database