Database Configuration

From Server rental store
Jump to navigation Jump to search
  1. Database Configuration

This article details the database configuration necessary for a robust and performant MediaWiki 1.40 installation. Proper database configuration is critical for handling the load of a busy wiki and ensuring data integrity. This guide assumes you have already installed a supported database system (MySQL/MariaDB, PostgreSQL, SQLite) and have basic familiarity with command-line administration.

Supported Databases

MediaWiki 1.40 officially supports the following database management systems:

  • MySQL (5.7 or later) / MariaDB (10.2 or later) - The most commonly used database for MediaWiki.
  • PostgreSQL (9.6 or later) - A powerful and standards-compliant database.
  • SQLite - Suitable for small, single-user wikis or testing environments. Not recommended for production.

The choice of database depends on your wiki's size, expected traffic, and administrative expertise.

Configuration File: LocalSettings.php

All database configuration is done within the `LocalSettings.php` file. This file is located in the root directory of your MediaWiki installation. You'll need to edit this file to provide the necessary connection details.

Here's a breakdown of the key configuration variables:

Variable Name Description Example (MySQL/MariaDB)
`$wgDBtype` Specifies the database type. `mysql`
`$wgDBserver` The hostname or IP address of the database server. `localhost`
`$wgDBname` The name of the database created for MediaWiki. `mediawiki_db`
`$wgDBuser` The database username. `mediawiki_user`
`$wgDBpassword` The database password. `your_secret_password`
`$wgDBport` The port number the database server listens on. `3306`
`$wgDBSSL` Enable SSL connection to the database server. `false`

Important Note: Never hardcode sensitive information like database passwords directly into `LocalSettings.php` if it's publicly accessible. Consider using environment variables or other secure methods for storing credentials. See Manual:Configuration settings for more advanced options.

Database Character Set and Collation

Correct character set and collation settings are crucial for handling multilingual content correctly. UTF-8 is the recommended character set for MediaWiki.

Database Character Set Collation
MySQL/MariaDB `utf8mb4` `utf8mb4_unicode_ci`
PostgreSQL `UTF8` `en_US.UTF-8` or `und.UTF-8` (locale-specific)
SQLite UTF-8 (handled internally) N/A

Ensure the database, tables, and connection settings all use the same character set (UTF-8) and collation. Incorrect settings can lead to data corruption or display issues with non-ASCII characters. You can set character set and collation during database creation or alter existing databases using SQL commands. Refer to your database's documentation for specific instructions. See Manual:Internationalization and localization for further details on internationalization.

Database Server Tuning

For production environments, tuning the database server is essential. Here are some recommended settings for MySQL/MariaDB. PostgreSQL optimization is more complex and requires understanding of its configuration parameters. Consult the PostgreSQL documentation for detailed guidance.

Parameter Description Recommended Value
`innodb_buffer_pool_size` The size of the buffer pool used by the InnoDB storage engine. 50-80% of available RAM
`innodb_log_file_size` The size of each InnoDB log file. 256M - 1G (depending on write load)
`max_connections` The maximum number of concurrent connections to the database. 150-500 (depending on traffic)
`query_cache_size` The size of the query cache. (Deprecated in MySQL 8.0) 0 (Generally disabled in modern versions)

Caution: Incorrectly configured database parameters can negatively impact performance. Always test changes thoroughly in a staging environment before applying them to production. Monitoring database performance using tools like `mysqltuner.pl` or PostgreSQL's built-in monitoring features is highly recommended. See Manual:Performance tuning for more information.

Database Maintenance

Regular database maintenance is vital for long-term performance and stability. This includes:

  • Backups: Regularly back up your database to protect against data loss.
  • Vacuuming: (PostgreSQL) Reclaim storage space occupied by deleted or updated rows.
  • Optimizing Tables: (MySQL/MariaDB) Reorganize table data to improve query performance.
  • Checking for Errors: Regularly check the database server logs for errors or warnings.
  • Updating MediaWiki: Keep MediaWiki updated to the latest version to benefit from performance improvements and security fixes. Manual:Upgrading provides instructions.

Related Pages


Intel-Based Server Configurations

Configuration Specifications Benchmark
Core i7-6700K/7700 Server 64 GB DDR4, NVMe SSD 2 x 512 GB CPU Benchmark: 8046
Core i7-8700 Server 64 GB DDR4, NVMe SSD 2x1 TB CPU Benchmark: 13124
Core i9-9900K Server 128 GB DDR4, NVMe SSD 2 x 1 TB CPU Benchmark: 49969
Core i9-13900 Server (64GB) 64 GB RAM, 2x2 TB NVMe SSD
Core i9-13900 Server (128GB) 128 GB RAM, 2x2 TB NVMe SSD
Core i5-13500 Server (64GB) 64 GB RAM, 2x500 GB NVMe SSD
Core i5-13500 Server (128GB) 128 GB RAM, 2x500 GB NVMe SSD
Core i5-13500 Workstation 64 GB DDR5 RAM, 2 NVMe SSD, NVIDIA RTX 4000

AMD-Based Server Configurations

Configuration Specifications Benchmark
Ryzen 5 3600 Server 64 GB RAM, 2x480 GB NVMe CPU Benchmark: 17849
Ryzen 7 7700 Server 64 GB DDR5 RAM, 2x1 TB NVMe CPU Benchmark: 35224
Ryzen 9 5950X Server 128 GB RAM, 2x4 TB NVMe CPU Benchmark: 46045
Ryzen 9 7950X Server 128 GB DDR5 ECC, 2x2 TB NVMe CPU Benchmark: 63561
EPYC 7502P Server (128GB/1TB) 128 GB RAM, 1 TB NVMe CPU Benchmark: 48021
EPYC 7502P Server (128GB/2TB) 128 GB RAM, 2 TB NVMe CPU Benchmark: 48021
EPYC 7502P Server (128GB/4TB) 128 GB RAM, 2x2 TB NVMe CPU Benchmark: 48021
EPYC 7502P Server (256GB/1TB) 256 GB RAM, 1 TB NVMe CPU Benchmark: 48021
EPYC 7502P Server (256GB/4TB) 256 GB RAM, 2x2 TB NVMe CPU Benchmark: 48021
EPYC 9454P Server 256 GB RAM, 2x2 TB NVMe

Order Your Dedicated Server

Configure and order your ideal server configuration

Need Assistance?

⚠️ *Note: All benchmark scores are approximate and may vary based on configuration. Server availability subject to stock.* ⚠️