# Switching from YAML (file) to MySQL (DB)

GWorld v2 features intelligent migration systems that make transitioning from older versions or switching between storage media (files to database) as easy as possible.

**Looking for information on migrating from v1 to v2? Then please follow this link: \[Migration from v1-legacy to v2\](https://books.gilljan.de/books/gworld-dokumentation-de/page/migration-von-v1-legacy-zu-v2 “Migration from v1-legacy to v2”)**

---

## Switching from YAML to MySQL

If you no longer want to store your world data locally in a file, but centrally in a MySQL database, GWorld v2 offers an automatic transfer service.

### Steps for the changeover

1. Stop your server.
2. <span style="white-space: pre-wrap;">Open </span>`<span class="editor-theme-code">config.yml</span>`<span style="white-space: pre-wrap;"> and set </span>`<span class="editor-theme-code">Storage.Type</span>`<span style="white-space: pre-wrap;"> to </span>`<span class="editor-theme-code">MYSQL</span>`.<p class="callout info"><span style="white-space: pre-wrap;">If </span>`<span class="editor-theme-code">Storage.Type</span>`<span style="white-space: pre-wrap;"> is missing, please update your config.yml. See: \[Standard configuration files\](https://books.gilljan.de/books/gworld-dokumentation-de/page/standard-konfigurationsdateien “Standard configuration files”)</span></p>
3. <span style="white-space: pre-wrap;">Enter your database access data in the </span>`<span class="editor-theme-code">MySQL</span>`<span style="white-space: pre-wrap;"> section.</span>
4. Restart the server.

### What happens at startup?

- **Data transfer:**<span style="white-space: pre-wrap;"> GWorld detects that MySQL is enabled, but a local </span>`<span class="editor-theme-code">worlds.yml</span>`<span style="white-space: pre-wrap;"> file with data still exists.</span>
- **Import:**<span style="white-space: pre-wrap;"> The plugin reads all worlds from the file and writes them to the corresponding MySQL tables.</span>
- **Completion:**<span style="white-space: pre-wrap;"> To prevent duplicate imports, the local file is renamed to </span>`<span class="editor-theme-code">worlds.yml.imported</span>`<span style="white-space: pre-wrap;"> after successful completion.</span>
- **Security:**<span style="white-space: pre-wrap;"> If a world already exists in the database, it is not migrated for security and integrity reasons.</span>

---

### Security measures &amp; requirements

To ensure a smooth migration, please note the following points:

#### Requirements

- **Database availability:**<span style="white-space: pre-wrap;"> If MySQL is configured, the plugin will abort the startup process if no connection can be established to prevent data loss.</span>

#### Checklist

- [ ] Ensure that the database user has permissions to create tables (`<span class="editor-theme-code">CREATE</span>`), insert (`<span class="editor-theme-code">INSERT</span>`) and modify (`<span class="editor-theme-code">UPDATE</span>`) data.
- [ ] Before switching, create a manual backup of your entire plugin folder.
- [ ] <span style="white-space: pre-wrap;">After switching, use the </span>`<span class="editor-theme-code">/gworlds</span>`<span style="white-space: pre-wrap;"> command to check that all worlds are listed correctly.</span>

---

**This documentation refers to GWorld version 2.0.1.**