Can't connect to MySQL - You have an error in your SQL syntax

プラットフォームについて: 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 fails to connect to MySQL database either when installing it or migrating databases. The following appears in the atlassian-bitbucket.log:

The schema could not be created. com.atlassian.bitbucket.internal.db.DefaultDatabaseManager.createSchema(DefaultDatabaseManager.java:317) com.atlassian.bitbucket.internal.db.DefaultDatabaseManager.prepareDatabase(DefaultDatabaseManager.java:161) com.atlassian.bitbucket.internal.maintenance.SpringMaintenanceTaskFactory.setupTask(SpringMaintenanceTaskFactory.java:145) ... Error creating bean with name 'liquibasePrototype' defined in class path resource [bitbucket-context.xml]: Invocation of init method failed; nested exception is liquibase.exception.MigrationFailedException: Migration failed for change set com/atlassian/caviar/db/changelog/r1_0/initial-schema.xml::initial-schema-03::mheemskerk: Reason: liquibase.exception.DatabaseException: Error executing SQL CREATE TABLE `nb-bitbucket`.`cwd_app_dir_mapping` (`id` BIGINT NOT NULL, `application_id` BIGINT NOT NULL, `directory_id` BIGINT NOT NULL, `allow_all` CHARACTER(255) NOT NULL, `list_index` INT NULL, CONSTRAINT `SYS_PK_10077` PRIMARY KEY (`id`), CONSTRAINT `FK_APP_DIR_DIR` FOREIGN KEY (`directory_id`) REFERENCES nb-bitbucket.cwd_directory(id), CONSTRAINT `FK_APP_DIR_APP` FOREIGN KEY (`application_id`) REFERENCES nb-bitbucket.cwd_application(id)): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-bitbucket.cwd_directory(id), CONSTRAINT `FK_APP_DIR_APP` FOREIGN KEY (`application_' at line 1: Caused By: Error executing SQL CREATE TABLE `nb-bitbucket`.`cwd_app_dir_mapping` (`id` BIGINT NOT NULL, `application_id` BIGINT NOT NULL, `directory_id` BIGINT NOT NULL, `allow_all` CHARACTER(255) NOT NULL, `list_index` INT NULL, CONSTRAINT `SYS_PK_10077` PRIMARY KEY (`id`), CONSTRAINT `FK_APP_DIR_DIR` FOREIGN KEY (`directory_id`) REFERENCES nb-bitbucket.cwd_directory(id), CONSTRAINT `FK_APP_DIR_APP` FOREIGN KEY (`application_id`) REFERENCES nb-bitbucket.cwd_application(id)): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-bitbucket.cwd_directory(id), CONSTRAINT `FK_APP_DIR_APP` FOREIGN KEY (`application_' at line 1: Caused By: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-bitbucket.cwd_directory(id), CONSTRAINT `FK_APP_DIR_APP` FOREIGN KEY (`application_' at line 1 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1553) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475) ... Migration failed for change set com/atlassian/caviar/db/changelog/r1_0/initial-schema.xml::initial-schema-03::mheemskerk: Reason: liquibase.exception.DatabaseException: Error executing SQL CREATE TABLE `nb-bitbucket`.`cwd_app_dir_mapping` (`id` BIGINT NOT NULL, `application_id` BIGINT NOT NULL, `directory_id` BIGINT NOT NULL, `allow_all` CHARACTER(255) NOT NULL, `list_index` INT NULL, CONSTRAINT `SYS_PK_10077` PRIMARY KEY (`id`), CONSTRAINT `FK_APP_DIR_DIR` FOREIGN KEY (`directory_id`) REFERENCES nb-bitbucket.cwd_directory(id), CONSTRAINT `FK_APP_DIR_APP` FOREIGN KEY (`application_id`) REFERENCES nb-bitbucket.cwd_application(id)): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-bitbucket.cwd_directory(id), CONSTRAINT `FK_APP_DIR_APP` FOREIGN KEY (`application_' at line 1: Caused By: Error executing SQL CREATE TABLE `nb-bitbucket`.`cwd_app_dir_mapping` (`id` BIGINT NOT NULL, `application_id` BIGINT NOT NULL, `directory_id` BIGINT NOT NULL, `allow_all` CHARACTER(255) NOT NULL, `list_index` INT NULL, CONSTRAINT `SYS_PK_10077` PRIMARY KEY (`id`), CONSTRAINT `FK_APP_DIR_DIR` FOREIGN KEY (`directory_id`) REFERENCES nb-bitbucket.cwd_directory(id), CONSTRAINT `FK_APP_DIR_APP` FOREIGN KEY (`application_id`) REFERENCES nb-bitbucket.cwd_application(id)): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-bitbucket.cwd_directory(id), CONSTRAINT `FK_APP_DIR_APP` FOREIGN KEY (`application_' at line 1: Caused By: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-bitbucket.cwd_directory(id), CONSTRAINT `FK_APP_DIR_APP` FOREIGN KEY (`application_' at line 1 liquibase.changelog.ChangeSet.execute(ChangeSet.java:347) liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:27) liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:58) ... Error executing SQL CREATE TABLE `nb-bitbucket`.`cwd_app_dir_mapping` (`id` BIGINT NOT NULL, `application_id` BIGINT NOT NULL, `directory_id` BIGINT NOT NULL, `allow_all` CHARACTER(255) NOT NULL, `list_index` INT NULL, CONSTRAINT `SYS_PK_10077` PRIMARY KEY (`id`), CONSTRAINT `FK_APP_DIR_DIR` FOREIGN KEY (`directory_id`) REFERENCES nb-bitbucket.cwd_directory(id), CONSTRAINT `FK_APP_DIR_APP` FOREIGN KEY (`application_id`) REFERENCES nb-bitbucket.cwd_application(id)): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-bitbucket.cwd_directory(id), CONSTRAINT `FK_APP_DIR_APP` FOREIGN KEY (`application_' at line 1 liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:62) liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:104) liquibase.database.AbstractDatabase.execute(AbstractDatabase.java:1091) ... You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-bitbucket.cwd_directory(id), CONSTRAINT `FK_APP_DIR_APP` FOREIGN KEY (`application_' at line 1 sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ...

原因

The issue here is that the MySQL documentation indicates that unquoted identifiers can only contain letters, numbers, $ and _. -'s (hyphens) are not supported in unquoted literals. The schema management tool Bitbucket Server uses (Liquibase) generally does a good job of escaping names for us, but sometimes it misses it. Bitbucket Server internally uses underscores in all of our names for this exact reason.

ソリューション

A name for the database like nbbitbucket or nb_bitbucket should work.

Just change the database name and reconnect.

更新日時: September 25, 2025

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

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