Bitbucket Server fails to connect to external database - The MSSQL database user is not configured with correct permission
Problem
The Bitbucket Server's Sys.Admin attempt to migrate from the internal or a different external database to MSSQL database via the database migration tool in Bitbucket Server UI. The attempt results in a failed migration due to the database user permission. The following trace is seen in the atlassian-bitbucket.log file:
Bitbucket does not have adequate permissions to modify the target database when connected as the specified user. Please check that the user has permission to CREATE and DROP tables and to INSERT and DELETE data. For information about creating a database for use with Bitbucket, please refer to the Bitbucket documentation.
com.atlassian.stash.internal.db.DefaultDatabaseManager.validateConfiguration(DefaultDatabaseManager.java:226)
com.atlassian.stash.internal.migration.DefaultDatabaseMigrationService.validateConfiguration(DefaultDatabaseMigrationService.java:85)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Cause
The MSSQL database user does not have proper permission to make the required changes in the database. It expected that the user to have at least the following permissions:
- CREATE
- INSERT
- DELETE
- DROP
Resolution
The Database Administrator should grant proper permission to the affected database user to allow the user to make changes to the database reflecting the changes in the Bitbucket Server. The following should be fix the permission issue:
GRANT CREATE, INSERT, DROP, DELETE ON <database> TO <database_user>
Replace the <database> to the database assigned to Bitbucket Server and <database_user> to the dedicated database user for Bitbucket Server.