SQL user (re-)creation error when migrating server (but not database)

We are migrating the server, but the database exists on a separate server, and that’s not changing. When installing Octo on the new server, it asks for the user that will be running the service, but then tries to recreate that user in the database, and stops on the error because it can’t. It seems like the SQL script should check to see if the user already exists before creating it.

Saving instance: OctopusServer
Setting home directory to: C:\Octopus
Overriding master key
Setting database connection string to: data source=████████████████████;initial catalog=███████████████;integrated security=True
========== SQL Database Connection Details ========
SQL Server: ████████████████████
SQL Database: ███████████████
Authentication Type: Windows Integrated Security
User: █████████████████

Processing user account '██████████████████'...
Creating server principal '██████████████████' as a new login from the Windows account with the same name...
Error: We are having trouble working with your SQL Database. This will usually be something you can fix. If not please contact support@octopus.com for help. Here are the error details: SQL Error 15247 - User does not have permission to perform this action.
Error: System.Data.SqlClient.SqlException
Error:    at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
Error:    at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
Error:    at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
Error:    at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
Error:    at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
Error:    at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
Error:    at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
Error:    at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
Error:    at Octopus.Core.RelationalStorage.RawSqlQueryExecutor.ExecuteNonQuery(String commandText, IDictionary`2 commandParameters, String connectionString, Nullable`1 commandTimeout)
Error:    at Octopus.Core.RelationalStorage.SqlServerManager.CreateLoginFromWindows(String name, String defaultDatabase, String defaultLanguage)
Error:    at Octopus.Server.Commands.DatabaseCommand.Start()
Error: The previous command returned a non-zero exit code of: 1
Error: The command that failed was: "C:\Program Files\Octopus Deploy\Octopus\Octopus.Server.exe" database --instance "OctopusServer" --connectionString "Data Source=████████████████████;Initial Catalog=███████████████;Integrated Security=True" --masterKey "████████████████████████████████████████" --grant "██████████████████"
Deleted instance: OctopusServer

Hi Brian,

Thanks for getting in touch and the suggestion. You can work around this problem by clicking on Show Script instead of Install at the end of the wizard. You can then run the commands from the commandline, removing the --grant option from the database command.


Rob W

Thanks, I wasn’t sure how to progress in the wizard (and use the admin utility) with just the script, so I ended up giving another account, then changing it back in the services control panel applet. Is the user stored anywhere else that I’d need to change?

No, that is the only place.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.