我正在尝试在 SQL Server Management Studio 中执行以下脚本:
USE [master] GO CREATE DATABASE [test1] ON PRIMARY ( NAME = N'test1', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\test1.mdf', SIZE = 70656KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB) LOG ON ( NAME = N'test1_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\test1_log.ldf', SIZE = 164672KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
但我收到错误:
Msg 5123, Level 16, State 1, Line 2 CREATE FILE encountered operating system error 5 (Access is denied.) while attempting to open or create the physical file ‘C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\test1.mdf’. Msg 1802, Level 16, State 4, Line 2 CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
Msg 5123, Level 16, State 1, Line 2 CREATE FILE encountered operating system error 5 (Access is denied.) while attempting to open or create the physical file ‘C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\test1.mdf’.
Msg 1802, Level 16, State 4, Line 2 CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
已经拥有我的用户的所有角色权限,有什么问题吗?
您收到权限错误。运行 SQL Server 的帐户对将包含数据库文件的文件夹没有所需的权限。
您需要授予运行 SQL Server 的帐户(不是您的帐户)对 C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA 的完全控制权。