Before you connect to Applications Manager's back-end database, it is important that you take a backup of the AppManager directory so that you don't make any changes/accidentally modify the database.
1. Identify which database Applications Manager is using. Navigate to <Applications Manager Home>\conf\ directory and open AMServer.properties file. Check the value of am.dbserver.type variable. If it is PGSQL, follow the steps given below. If it is MySQL, you will migrate to a different database as Applications Manager does not support MySQL anymore. (From v16240)
PostgreSQL database (Standalone Applications Manager):
Connect to the PGSQL database through the following commands one by one from the server in which Applications Manager has been installed.
Windows:
1. Open command prompt. Navigate to the following directory:
<AppManagerHome>\working\pgsql\bin
2. Execute the following commands one by one.

set PGPASSWORD=appmanager
psql -p 15432 -U postgres -h localhost -d amdb
Note: In the above commands, "amdb" is the name of the database of Applications Manager.
15432 is the port on which Applications Manager's PGSQL database runs (you can get this value from <Applications Manager Home>\conf\AMServer.properties file, by checking the value of am.db.port variable ).Sample screenshot:
Linux:
1. Open terminal. Navigate to the following directory:
<AppManagerHome>/working/pgsql/bin
2. Execute the following commands one by one.

export PGPASSWORD=appmanager
./psql -p 15432 -U postgres -h localhost -d amdb
Note: In the above commands, "amdb" is the name of the database of Applications Manager.
15432 is the port on which Applications Manager's PGSQL database runs (you can get this value from <Applications Manager Home>\conf\AMServer.properties file, by checking the value of am.db.port variable ).Sample screenshot:
APM Plugin (Applications Manager plugin installed on OpManager):
1. Open command prompt/terminal and navigate to <OpManager home>/pgsql/bin directory.
2. Execute the following command:
Windows:

psql -p 13306 -U postgres -h localhost -d amdb
Linux:

./psql -p 13306 -U postgres -h localhost -d amdb
Note: Follow the below steps to connect to the Applications Manager plugin DB if OpManager's PGSQL DB has been upgraded to version 12.5.xx :
1. Connect to the OpManager DB using the below command:
psql.exe -U dbuser -h 127.0.0.1 -p 13306 <OpManager DB Name>2. Then enter the password for user dbuser.
3. Once connection to the database is successful, to list the databases inside the OpManager DB, enter the following command:

\l
4. After checking Applications Manager's plugin database name, enter the following command:

\c <DB name>
Example: \c amdb
5. Now it will connect to the Applications Manager plugin database.
MySQL Database: (Now deprecated)
Windows:
1. Open command prompt. Navigate to the following directory:
<AppManagerHome>\working\mysql\bin
2. Execute the following command:

mysql.exe -h localhost -u root -P 13326 -pappmanager -D AMDB -A

Note: In the above commands, AMDB is the name of the database of Applications Manager.
13326 is the port on which Applications Manager's MySQL database runs (you can get this value from <Applications Manager Home>\conf\AMServer.properties file, by checking the value of am.db.port variable ).
Linux:
1. Open terminal. Navigate to the following directory:
<AppManagerHome>/working/mysql/bin
2. Execute the following command:

mysql -h localhost -u root -pappmanager --socket=./../mysql.sock -D AMDB -A
Note: In the above commands, AMDB is the name of the database of Applications Manager.
Sample screenshot:
Troubleshooting PGSQL Connection refused error:
In the AppManager server, please open the WordPad with admin rights and open the hosts file present under C:\Windows\system32\drivers\etc\ directory or under /etc directory in case of Linux then remove the comment hashtag (#) symbol as shown below and save it.
# 127.0.0.1 localhost
to
127.0.0.1 localhost
In the same location if you have IPV6 entry in hosts file, comment that and save the file.
# ::1 localhost
In the same location if you have IPV6 entry in hosts file, comment that and save the file.
#::1 localhost6.localdomain6 localhost6