Connect to Authentication Manager 8.x Database to View or List Database Objects
Before making any changes to the database, make a back up of the database and store the backup in a secure location.
- Create a read-only database user. In the example below, the users ocaadmin and rouser are used only for examples.
cd /opt/rsa/am/utils ./rsautil manage-readonly-dbusers -a create -o ocadmin -u rouser -i <IP address where SSH is enabled> Enter Operations Console (OC) password: <enter Operations Console admin user name> Enter password for the read-only database user: <enter password for the read-only user> Confirm password for the read-only database user: <confirm password for the read-only user> Executing action: 'create'. Trusted Root SSL CA certificate was copied in file '/opt/rsa/am/utils/RSAAMTrustedRootSSLCA.crt'. 'create' action complete.
- From the command line, connect to the database as the read-only user. Query the database using a SELECT statement. Note that the statement must be enclosed in single quotes and must end with a semicolon:
cd /opt/rsa/am/pgsql/bin ./psql -h localhost -p 7050 -d db -U rouser -c 'SELECT name FROM am_host;' Password for user rouser: <enter password for the read-only database user>
Sample output is as follows:
name ------------------------------------ 2k8r2-lac72-1.2k8r2-vcloud.local am8p.vcloud.local
- To output the results of the query above to a file, add the -o option. There will be no screen output when using this option. The resulting am_agent_list.csv file will be written to /opt/rsa/am/pgsql/bin.
./psql -h localhost -p 7050 -d db -U rouser -o myfilename.csv -c 'SELECT name FROM am_host;'
- The SELECT statement also can be written in a file and run as in the example below:
cd /opt/rsa/am/pgsql/bin ./psql -h localhost -p 7050 -d db -U rouser -f /path_to_file/mysqlquery.sql Password for user rouser: <enter password for the read-only database user>
- Query the database using a SELECT statement from the psql command line:
cd /opt/rsa/am/pgsql/bin ./psql -h localhost -p 7050 -d db -U <read-only user>
db=> SELECT serial_number FROM rsa_rep.am_token;
Sample output:
serial_number --------------- 000112259786 000112259787
- When done, use \q to exit the pgSQL database command line:
db=> \q
|