DBAtlas · Database operations atlas

Connect from the command line (CLI / connection string)

Oracle

sqlplus app_user/password@//host:1521/service_name
# As SYSDBA: sqlplus sys/password@//host:1521/orcl AS SYSDBA

//host:port/service is the 'Easy Connect' format; alternatively, use a TNS alias from tnsnames.ora.

PostgreSQL

psql -h host -p 5432 -U postgres -d mydb
# With a URI: psql "postgresql://app_user:password@host:5432/mydb?sslmode=require"

To avoid typing the password on the command line, use a ~/.pgpass file or the PGPASSWORD environment variable.

MySQL

mysql -h host -P 3306 -u root -p mydb
# Require TLS: --ssl-mode=REQUIRED

Pass -p on its own (you are prompted for the password); the 'mysql -pPassword' form exposes the password in the process list.

SQL Server

sqlcmd -S host,1433 -U sa -P password -d mydb
# Windows authentication: sqlcmd -S host -E -d mydb

In the newer go-sqlcmd, the -C (trust server certificate) and -N (encrypt) flags may be needed for TLS.

MongoDB

mongosh "mongodb://app_user:password@host:27017/mydb?authSource=admin"
# Replica set: ...mongodb://h1,h2,h3/db?replicaSet=rs0

authSource is usually the database where the user is defined (most often admin).

Redis

redis-cli -h host -p 6379 -a password
# With TLS: redis-cli -h host -p 6379 --tls -a password
# Redis 6+ ACL: redis-cli -h host --user app --pass password

-a passes the password on the command line (prints a warning); for secure login use the REDISCLI_AUTH environment variable.

Open in DBAtlas →