CREATE DATABASE permission denied in database 'master'

Proposed CREATE DATABASE permission denied in database 'master'

  • 19 februarie 2012 05:01
     
     

    I'm simply following this tutorial:  http://www.windowsazure.com/en-us/develop/net/tutorials/web-app-with-sql-azure/

    In Step 8 when running the app via F5 from Visual Studio I get:

    [SqlException (0x80131904): CREATE DATABASE permission denied in database 'master'.]
       System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +404
       System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +412
       System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1363
       System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async) +2899484
       System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +504
       System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +327
       System.Data.SqlClient.<>c__DisplayClassa.<DbCreateDatabase>b__7(SqlConnection conn) +152
       System.Data.SqlClient.SqlProviderServices.UsingConnection(SqlConnection sqlConnection, Action`1 act) +144
       System.Data.SqlClient.SqlProviderServices.UsingMasterConnection(SqlConnection sqlConnection, Action`1 act) +3981711
       System.Data.SqlClient.SqlProviderServices.DbCreateDatabase(DbConnection connection, Nullable`1 commandTimeout, StoreItemCollection storeItemCollection) +315
       System.Data.Objects.ObjectContext.CreateDatabase() +260
       System.Data.Entity.Internal.DatabaseOperations.Create(ObjectContext objectContext) +53
       System.Data.Entity.Database.Create() +133
       System.Data.Entity.CreateDatabaseIfNotExists`1.InitializeDatabase(TContext context) +713

    ...

    My SQL Server services are running under NT AUTHORTY\NETWORK SERVICE
    Not sure what the Storage Emulator is running under (default install).

    I launched Visual Studio As Administrator.

    What am I missing?

    • Mutat de Yi-Lun LuoModerator 19 februarie 2012 13:59 Off topic. (From:Windows Azure Development)
    •  

Toate mesajele

  • 19 februarie 2012 23:46
     
     Răspuns propus
    You need to have permission for NY Authority\NetworkService in SQL Server to be able to create database. Try creating a new login for Network Service and provide it appropriate rights. I would suggest to use a sql authentication and sql user login in the connection string instead, and provide it appropriate rights.
  • 20 februarie 2012 16:56
     
     
    I haven't been through this tutorial, but it sounds like you must have changed logins at some point. The only logins that can create databases are the login that was created when you setup SQL Azure and any other logins that you made a member of the dbmanager role. Managing Databases and Logins in SQL Azure http://msdn.microsoft.com/en-us/library/ee336235.aspx

    Rick Byham, Microsoft, SQL Server Books Online, Implies no warranty

  • 21 februarie 2012 07:35
     
     

    Ok, I'm completely lost now. I'm not even sure at this point whether I have SQL Azure. I installed the Visual Studio Web Developer 2010 Express. I guess I got that from http://www.windowsazure.com/en-us/develop/net/

    It came with the Azure project templates and the compute and storage emulator.

    I also have SQL Server 2008 R2 and an instance called SQLEXPRESS which I can connect to from Visual Studio.

    When I looked at the article you linked to I noticed that don't have any SQL management tools. I don't have the SQL management studio and even when I download the installer it just kicks me into the SQL Server installation center which doesn't offer an option to install the management studio.

    I'm not sure where to go from here...

  • 21 februarie 2012 16:25
     
     

    SQL Server Management Studio is available at http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=7593

    I'm not sure what kind of SQL Azure offer you might have access to. If you need to, start with a Windows Azure account http://www.windowsazure.com/en-us/pricing/free-trial/


    Rick Byham, Microsoft, SQL Server Books Online, Implies no warranty

  • 23 februarie 2012 02:33
     
     

    That's where I went for the SQL management studio install but like I said after downloading the whole thing it simply starts the SQL Express maintenance setup.

    I signed up for the 3 month free Azure trial and downloaded the .NET tools that come with that.

    http://www.windowsazure.com/en-us/pricing/free-trial/

    http://www.windowsazure.com/en-us/develop/net/

  • 23 februarie 2012 16:40
     
     
    Regarding Management Studio, it is part of SQL Server Express, so that's how the installer is labeled. If you go through the setup program, this version will eventually only offer you  management tools and client connectivity. No Database Engine.

    Rick Byham, Microsoft, SQL Server Books Online, Implies no warranty

  • 6 aprilie 2012 04:22
     
     

    Have you had any luck solving this? I am running into the same issue and haven't found a solution.

  • 11 aprilie 2012 08:18
     
     

    In SQL Azure you don't have the ability to use integrated security, the user which is trying to create de database must be a member of dbmanager role, so you need to create the connection using an explict SQL Login. Tipically, to create a database the user should be the administrator, or you have to use the administrator to create a login with the appropiated permissions:

    CREATE LOGIN login1 WITH password='<ProvidePassword>';
    CREATE USER login1User FROM LOGIN login1;
    EXEC sp_addrolemember 'dbmanager', 'login1User';
    EXEC sp_addrolemember 'loginmanager', 'login1User'

    Then, you can create a database while connected to the MASTER database.

    As mentioned below, review  Managing Databases and Logins in SQL Azure http://msdn.microsoft.com/en-us/library/ee336235.aspx

    Other interesting references:

    How to: Connect to SQL Azure Using ADO.NEThttp://msdn.microsoft.com/en-us/library/ee336243.aspx

    Guidelines for Connecting to SQL Azure Database http://msdn.microsoft.com/en-us/library/ee336282.aspx