Accessing Bitbucket Server's H2 embedded database


アトラシアン コミュニティをご利用ください。


プラットフォームについて: サーバーと Data Center のみ。この記事は、サーバーおよび Data Center プラットフォームのアトラシアン製品にのみ適用されます。


While the H2 database is not supported for production environments, sometimes admins will need access for testing purposes or you may need to run some diagnostics on a Bitbucket mirror's H2 database.


Before accessing or modifying the H2 embedded database, it's always recommended to first make a backup of $BITBUCKET_HOME/shared/data/db.h2.db

  1. Bitbucket Server を停止します。
  2. Login to the server as the user that runs Bitbucket Server
  3. Run the following command which will open a console connection to the database:

    java -cp <BITBUCKET_INSTALLATION>/app/WEB-INF/lib/h2-1.3.176.jar

    Update the path above to reflect where Bitbucket Server is installed

  4. When prompted for the URL enter:

    Update the path above to reflect the location of the Bitbucket Home directory
  5. Press enter to select default (org.h2.Driver) when asked which driver to use
  6. Enter sa for the user
  7. Press enter twice when prompted for the password (no password is required)

If successful, you'll be prompted with sql> and can enter any SQL commands required.

コマンド ライン オプション

It is also possible to combine the steps to connect to the database in a single command:

java -cp <BITBUCKET_INSTALLATION>/app/WEB-INF/lib/h2-1.3.176.jar -url "jdbc:h2:file://<BITBUCKET_HOME>/shared/data/db;DB_CLOSE_ON_EXIT=TRUE" -driver org.h2.Driver -user sa 

To connect and then run a query, pass the -sql option and the SQL query, for example:

java -cp <BITBUCKET_INSTALLATION>/app/WEB-INF/lib/h2-1.3.176.jar -url "jdbc:h2:file://<BITBUCKET_HOME>/shared/data/db;DB_CLOSE_ON_EXIT=TRUE" -driver org.h2.Driver -user sa -sql "SELECT * FROM app_property;"
Update the paths above to reflect the location of the Bitbucket installation and home directories

最終更新日 2021 年 8 月 9 日


Powered by Confluence and Scroll Viewport.