Avatar of Mark
Mark
 asked on

Unable to connect to SQL Server 2005 database on Virtual Machine

I have installed an XP virtual machine on a Linux host. Everything seems to work OK except I cannot connect to the database from clients elsewhere on the LAN. I am using port 1433. I *can* telnet to this port, so that tells me the SQL Server is listening to this port on the VM, but when I try to connect I get the error:

Status: 4064 Cannot open user default database. Login failed. ClientConnectionId:d5cd574a-3189-4831-8245-5ab0abc3124b

connection string is:

Driver: com.microsoft.sqlserver.jdbc.SQLServerDriver
URL: jdbc:sqlserver://192.168.0.2:1433

I can still successfully connect to the original, physical XP host. Its connection string is:

Driver: com.microsoft.sqlserver.jdbc.SQLServerDriver
URL: jdbc:sqlserver://192.168.0.59:1433;

I've checked SQL Configuration Manager > Protocols ... > TCP/IP, and that looks OK - Any ideas where I might look?
SQL Configuration Manager
Microsoft SQL Server

Avatar of undefined
Last Comment
Mark

8/22/2022 - Mon
HainKurt

looks like you are trying to connect to master db

so, check login/username and set the default db

are you giving the databasename to connect to?
Nakul Vachhrajani

In SQL 2005, there is also something known as the surface area configuration manager which has a switch whether or not to allow remote connections to the SQL Server instance. If unchecked, can you please check the flag and try?
Mark

ASKER
Huseyin KAHRAMAN:
looks like you are trying to connect to master db
Actually, I was not trying to connect to master, but when I connected using the 'sa' user (default db is master) and did a query, it worked!

Upon further investigation, I found the problem. The user database files  reside on the D: drive on the physical XP server. However, the D: drive on the Virtual Machine is the DVD drive. The is no physical/virtual 2nd drive on the VM, but I can subst an e.g. E: drive for a directory on the VM's C: drive. The problem is, how do I tell SQL Server that the database files are on the E: drive, not the D: drive? Is there a way to do this?
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
HainKurt

you can set DVD as X and subst whatever you need to D

and no need to change anything on sql
ASKER CERTIFIED SOLUTION
HainKurt

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Vitor Montalvão

Status: 4064 Cannot open user default database. Login failed.
Which login are you using? Not 'sa' login and neither a login with sysadmin role, right?

The user database files  reside on the D: drive on the physical XP server. However, the D: drive on the Virtual Machine is the DVD drive.
What are the status for the user databases? Are they marked as suspect? Offline? Online? Other?
Nakul Vachhrajani

The user database files  reside on the D: drive on the physical XP server. However, the D: drive on the Virtual Machine is the DVD drive.

In this case, the databases should not even be available on the VM server - they would be offline or suspect. If your databases are online, then the path in the VM should not matter for connecting to the database. Are we missing something in your architecture here?
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Mark

ASKER
Huseyin, that was exactly right! I used Control Panel > Administrative Tools > Computer Management > Disk Management > right-clicked on D: > Change Drive Letter and Paths. I then changed the DVD to E:.

I was able to expand the whole 1TB volume to use as C:, and I restored the former D: drive to C:\SQLServerData.

I did not use subst to remap as that mappage is lost upon reboot. Instead, I created a file, mapDdrive.reg with the following contents:
[code]
REGEDIT4
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices]
"D:"="\\??\\C:\\SQLserverData"
[/code]
and ran that to create the specified registry setting. This has the advantage of persisting between boots and being processed before services are started. See https://superuser.com/questions/29072/how-to-make-subst-mapping-persistent-across-reboots for details.

I tested this all from a remote SQLServer connection using a Java program and it worked! I was able to query the database w/o problem.

btw - I'd like to print a hard-copy of this solution. Does anyone know where EE has once again hidden the print button/icon/link?