refactor: import the sql file when the service starts

This commit is contained in:
gin
2026-05-08 15:27:50 +08:00
parent fdae916d12
commit cc20e89161
3 changed files with 35 additions and 4 deletions
+26 -3
View File
@@ -34,8 +34,31 @@ cd backend
docker compose up -d
```
On a fresh Docker volume, Compose creates the MySQL database `agileboot_pure`.
Import the SQL files under `backend/sql/` before starting the backend.
The compose configuration mounts `backend/sql/agileboot.sql` into the MySQL
container as `/docker-entrypoint-initdb.d/01-agileboot.sql`.
The official MySQL image only runs files in `/docker-entrypoint-initdb.d` when
the database directory is empty, during the first initialization of the
`mysql_data` volume.
If MySQL has already been started before, the `mysql_data` volume already
contains data and `docker compose up -d` will not import the SQL again. To
reinitialize the local database, remove the volumes first:
```bash
cd backend
docker compose down -v
docker compose up -d
```
Warning: `docker compose down -v` deletes the local MySQL and Redis volumes,
including existing database data and Redis data.
If you do not want to delete the volumes, import the SQL manually:
```bash
cd backend
docker exec -i mysql-server mysql -uroot -proot123 agileboot_pure < sql/agileboot.sql
```
### Install Frontend Dependencies
@@ -50,7 +73,7 @@ Start the backend:
```bash
cd backend
./mvnw -pl agileboot-admin -am spring-boot:run
./mvnw -pl agileboot-admin spring-boot:run
```
Start the web frontend: