5

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?

3 Answers 3

19

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

6

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)

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.