0

I get the error

Msg 5123, Level 16, State 1, Line 1
CREATE FILE encountered operating system error 5(Access is denied.) while attempting to open or create the physical file

after launching a localDb server and trying to run a create database query off it. I am very new to SQL Server and need to do a tutorial for an internship I am starting.

I created a localdb instance in my onedrive directory. At least I think I did because that's the directory I navigated to when I ran the

sqllocaldb c "LocalDBdemo" 14.0.1000.169

command on my command prompt (I use Hyper):

enter image description here

So why is it that SQL Server Management Studio v17.9.1 is trying to create an .MDF file in my C:\users\ directory?

enter image description here

It wants to put it in C:\users. Why not put it into the directory I created in Onedrive?

A solution I saw which I did was to make my c:\users directory accessible to everyone under permissions. I didn't want to do it but I did and it worked. But why do I even need to do this when I am running the program from within my windows user admin account which is the only account on my computer? Also how do I get SQL Server Mgmt Studio to create my .MDF databases wherever I choose?

4

1 回答 1

1

只需在创建数据库时指定适当的位置:

CREATE DATABASE Customer 
ON (NAME='Customer_Data', FILENAME='C:\AppropriatePath\Customer.mdf')
LOG ON (NAME='Customer_Log', FILENAME='C:\AppropriatePath\Customer.ldf');
于 2020-05-10T04:41:38.253 回答