Cannot connect Bitbucket Server to MySQL database

プラットフォームについて: Data Center のみ。 - This article only applies to Atlassian apps on the Data Center プラットフォーム

この KB は Data Center バージョンの製品用に作成されています。Data Center 固有ではない機能の Data Center KB は、製品のサーバー バージョンでも動作する可能性はありますが、テストは行われていません。 Server* 製品のサポートは 2024 年 2 月 15 日に終了しました。Server 製品を実行している場合は、 アトラシアン Server サポート終了 のお知らせにアクセスして、移行オプションを確認してください。

*Fisheye および Crucible は除く

症状

Bitbucket Server fail to connect to MySQL database. The following appears in the atlassian-bitbucket.log:

2012-11-27 21:38:56,806 INFO [http-7990-5] 1298x15x1 1aan3w6 0:0:0:0:0:0:0:1%0 "POST /setup HTTP/1.1" c.a.s.i.m.DefaultMigrationService Setting up external database at jdbc:mysql://localhost:3306/bitbucket131?autoReconnect=true&characterEncoding=utf8&useUnicode=true&sessionVariables=storage_engine%3DInnoDB 2012-11-27 21:39:01,305 WARN [http-7990-5] 1298x15x1 1aan3w6 0:0:0:0:0:0:0:1%0 "POST /setup HTTP/1.1" c.a.s.i.m.DefaultMigrationService A connection could not be opened with the DataSource com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.6.0_37] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) ~[na:1.6.0_37] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) ~[na:1.6.0_37] at java.lang.reflect.Constructor.newInstance(Constructor.java:513) ~[na:1.6.0_37] at com.mysql.jdbc.Util.handleNewInstance(Util.java:411) ~[mysql-connector-java-5.1.17.jar:na] at com.mysql.jdbc.Util.getInstance(Util.java:386) ~[mysql-connector-java-5.1.17.jar:na] at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1013) ~[mysql-connector-java-5.1.17.jar:na] at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987) ~[mysql-connector-java-5.1.17.jar:na] at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:982) ~[mysql-connector-java-5.1.17.jar:na] ... Caused by: java.sql.SQLException: Unexpected exception encountered during query. ... Caused by: java.lang.NullPointerException: null at com.mysql.jdbc.ConnectionImpl.getServerCharacterEncoding(ConnectionImpl.java:3100) ~[mysql-connector-java-5.1.17.jar:na] at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2095) ~[mysql-connector-java-5.1.17.jar:na]

原因

This is a bug in MySQL driver 5.1.16 which causes an error in the connection when the JDBC URL has both "sessionVariables" and "characterEncoding" parameters at the same time (ie. url="jdbc:mysql://localhost:3306/bitbucket131?autoReconnect=true&characterEncoding=utf8&useUnicode=true&sessionVariables=storage_engine%3DInnoDB")

ソリューション

Upgrade to the latest MySQL driver version.

Tested to be working with MySQL driver 5.1.22

更新日時: September 25, 2025

さらにヘルプが必要ですか?

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