dbprobe - Linux


Overview

dbprobe is a versatile Linux command used to test and monitor database connections, diagnose connectivity issues, and perform debugging tasks. It can connect to various database types, including MySQL, PostgreSQL, Oracle, SQLite, and more.

Syntax

dbprobe [options] <hostname>:<port> <username> <password>

Required Arguments:

  • hostname: IP address or domain name of the database server.
  • port: Port number used by the database server.
  • username: Username used to connect to the database.
  • password: Password used to connect to the database.

Options/Flags

  • -d, –database: Specify the database name to connect to (default: empty).
  • -t, –timeout: Set the connection timeout in seconds (default: 5).
  • -v, –verbose: Enable verbose output, showing detailed connection information.
  • -h, –help: Display the help message and exit.
  • -V, –version: Display the version of dbprobe and exit.

Examples

Simple Connection Test:

dbprobe localhost:3306 root my_password

Connect to a Specific Database:

dbprobe localhost:3306 root my_password -d example_database

Verbose Debugging:

dbprobe localhost:3306 root my_password -v

Common Issues

  • Connection Refused: Ensure that the database server is running and listening on the specified port.
  • Wrong Credentials: Verify that the username and password entered are correct for the database.
  • Permission Denied: Make sure the user has the necessary permissions to access the database.
  • Database Not Found: Check if the specified database exists and is accessible.

Integration

Database Monitoring Script:

#!/bin/bash
dbprobe localhost:3306 root my_password -d example_database -v > logfile

Connect and Execute Query:

dbprobe localhost:3306 root my_password -d example_database <<EOF
SELECT * FROM users;
EOF

Related Commands

  • mysqladmin: MySQL command-line client for administration tasks.
  • psql: PostgreSQL command-line client for interactive querying.
  • sqlite3: Command-line tool for interacting with SQLite databases.