Verified Solution[StackOverflow/docker] mediadb_docker mediawiki MYSQL_DATABASE
Sponsored Content
### ROOT CAUSE
The issue arises because the `MYSQL_DATABASE` environment variable is not properly set in the Docker Compose configuration for the MediaWiki setup. This variable is required by the MySQL container to create and use the specified database. Without it, the MediaWiki service may fail to initialize or connect to the database.
### CODE FIX
1. **Ensure `MYSQL_DATABASE` is set in `docker-compose.yml`**: Add or verify the `MYSQL_DATABASE` environment variable in the MySQL service section of your `docker-compose.yml` file. For example:
```yaml
services:
db:
image: mysql:8.0
environment:
MYSQL_ROOT_PASSWORD: your_root_password
MYSQL_DATABASE: mediawiki_db # <-- Add this line
MYSQL_USER: mediawiki_user
MYSQL_PASSWORD: mediawiki_pass
```
2. **Verify Database Creation**: If the database still doesn’t exist, explicitly create it using a MySQL client or a script. For example:
```sql
CREATE DATABASE IF NOT EXISTS mediawiki_db;
```
3. **Check MediaWiki Configuration**: Ensure the `LocalSettings.php` file in the MediaWiki container references the correct database name (`mediawiki_db`).
4. **Rebuild Containers**: After making changes, rebuild the containers with:
```bash
docker-compose up -d --force-recreate
```
This ensures the database is created and properly linked to the MediaWiki service.
Deploy on DigitalOcean ($200 Credit)
Related Fixes
[StackOverflow/python] How can I shorten this border checking code?
[golang/go] runtime: Windows crash with Go 1.26.0, 1.26.1
[microsoft/vscode] "Report Issue" not able to find via search bar in the help Manu of vsc on Mac