February 4, 2018 at 5:39 pm
I think I just did a dumb thing and didn't properly detach my databases before reinstalling SQL Server 2016. When I try to attach, it fails:CREATE DATABASE Galactic2
ON (FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Galactic.mdf'),
(FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Galactic._Log.ldf')
FOR ATTACH;
Error:
Msg 5120, Level 16, State 101, Line 3
Unable to open the physical file "C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Galactic.mdf". Operating system error 2: "2(The system cannot find the file specified.)".
Msg 1802, Level 16, State 7, Line 3
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
I'm working on my laptop, and I'm the local admin. Still no joy. What am I doing wrong? Do I have to change the permissions on the individual MDF and LDF files?
February 4, 2018 at 6:37 pm
pietlinden - Sunday, February 4, 2018 5:39 PMI think I just did a dumb thing and didn't properly detach my databases before reinstalling SQL Server 2016. When I try to attach, it fails:CREATE DATABASE Galactic2
ON (FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Galactic.mdf'),
(FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Galactic._Log.ldf')
FOR ATTACH;Error:
Msg 5120, Level 16, State 101, Line 3
Unable to open the physical file "C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Galactic.mdf". Operating system error 2: "2(The system cannot find the file specified.)".
Msg 1802, Level 16, State 7, Line 3
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.I'm working on my laptop, and I'm the local admin. Still no joy. What am I doing wrong? Do I have to change the permissions on the individual MDF and LDF files?
Does the SQL Server service account have NTFS privs to the file? If not, you have have to adjust the permissions.
I know your error refers to the MDF file, but I also have to ask if your log filename is correct. You have it as "Galactic._Log.ldf", with a period before the underscore. It may be right; just wanted to make sure.
February 4, 2018 at 7:21 pm
The MSSQLSERVER (NT Service) has full permissions to the file(s). I never moved the files between uninstalling SQL Server and reinstalling it. Still no joy.
February 5, 2018 at 12:03 am
The error's a 'file not found', so the obvious question is, is the file there?
Double-check that path please, because it doesn't look correct
C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Galactic.mdf
With default installation settings, that should be C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data\Galactic.mdf
Similar for the log file (whose name also looks wrong, Galactic_log.ldf would be the default name)
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
March 8, 2018 at 2:08 am
This was removed by the editor as SPAM
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply