coze-dev / coze-dev/coze-studio

MySQL init SQL fails with “No database selected” (missing USE)

Open
#2,605 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
21.6k
Forks
3.1k
PR merge metrics
No merged PRs in 30d

Description

## 描述
啟動 MySQL 容器時,初始化 SQL 執行失敗,錯誤為:
`ERROR 1046 (3D000) at line 4: No database selected`

初始化 SQL 內有 `CREATE DATABASE`,但沒有 `USE ` 或全限定表名,導致後續 `CREATE TABLE` 報錯。

## 影響檔案
`docker/volumes/mysql/schema.sql`

## 重現步驟
1. 使用乾淨資料目錄啟動 MySQL 容器(刪除現有 volume/資料夾)
2. 讓容器執行 `docker/volumes/mysql/schema.sql`
3. 觀察日誌

## 實際結果
初始化失敗,出現:
`ERROR 1046 (3D000) at line 4: No database selected`

## 預期結果
應該成功建立 schema 與所有表

## 建議修正
在 SQL 檔中加上:
```sql
CREATE DATABASE IF NOT EXISTS opencoze COLLATE utf8mb4_unicode_ci;
USE opencoze;

Contributor guide

Open the contributing guide

Research direction

Open docker/volumes/mysql/schema.sql and inspect the initialization statements around the reported failure at line 4. Start by running the SQL against a clean MySQL data directory, then verify that initialization completes and the schema and all tables are created successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, mysql, sql
Domain
databases
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.