user2499454
user2499454

Reputation: 197

CMD test database connection

I setup a site on my localhost and I am getting unable to connect to database errors. (its not my local database) and now I am trying to connect to that database in the command line to see if its a firewall issue or php issue.

Whats the command to test a database connection (not local) in cmd?

Upvotes: 6

Views: 48029

Answers (3)

Mike Circuitry
Mike Circuitry

Reputation: 890

Here is a quick way you can test for database connectivity with no other database software installed :

  1. Create a new text file anywhere on the computer
  2. Rename the file and make the extentsion .udl (TestConnection.udl)
  3. When prompted about changing the extension select "Yes"
  4. Double click the file and Boom! Instant database connection tool

enter image description here

Upvotes: 23

Ansgar Wiechers
Ansgar Wiechers

Reputation: 200273

It depends very much on which database you want to connect to. MySQL? Oracle? PostgreSQL? SQL Servrer? DB2? Filemaker? Informix? One thing you could try is opening an ADO connection with VBScript:

Set conn = CreateObject("ADODB.Connection")
conn.Open "..."
WScript.Echo conn.State
conn.Close

Replace "..." with a connection string matching your database.

Upvotes: 0

Luca Clavarino
Luca Clavarino

Reputation: 434

It depends on what kind of database are you trying to connect to.

e.g. if you're connecting to Oracle db you may use something like this:

sqlplus <user>/<password>@<service>

if it's a Microsoft SQL Server you may use

osql -U<user> -P<password> -S<instance>

If you just want to test network ports to be sure no firewall is preventing connection, you can use telnet tool,

telnet <server-address> <service-port>

(default tcp port for Oracle db service is 1521, for SQL Server's 1433)

Upvotes: 7

Related Questions