$wgDBtype

From Server rental store
Revision as of 03:42, 16 April 2025 by Admin (talk | contribs) (Automated server configuration article)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
  1. Understanding and Configuring $wgDBtype in MediaWiki

This article provides a comprehensive overview of the `$wgDBtype` configuration variable in MediaWiki 1.40, aimed at newcomers to MediaWiki server administration. It details what `$wgDBtype` does, supported database types, configuration considerations, and troubleshooting tips. Properly configuring this variable is critical for a stable and performant wiki.

What is $wgDBtype?

`$wgDBtype` is a global PHP variable within the `LocalSettings.php` file that specifies the type of database backend MediaWiki will use to store its data. MediaWiki supports a variety of database systems, each with its own strengths and weaknesses. Selecting the appropriate database is crucial for performance, scalability, and maintainability. Incorrectly setting `$wgDBtype` will lead to errors and a non-functional wiki. It is one of the very first configurations you must get correct. See Manual:Configuration settings for more general information.

Supported Database Types

MediaWiki 1.40 officially supports the following database types. Each has its own dependencies and configuration nuances, detailed below.

Database Type Description Common Use Cases Performance Characteristics
MySQL/MariaDB The most commonly used database for MediaWiki. Mature, well-documented, and widely available. Small to large wikis, most general use cases. Generally good performance, especially with proper indexing and caching. PostgreSQL A powerful, open-source object-relational database system. Known for its data integrity and advanced features. Large wikis, wikis requiring high data integrity, complex queries. Excellent performance, particularly with complex queries, but may require more tuning. SQLite A self-contained, serverless, zero-configuration, transactional SQL database engine. Small wikis, testing environments, single-user wikis. Suitable for very small datasets, but performance degrades rapidly with scale. Not recommended for production.

Configuration Details

After selecting a database type, you must configure the `$wgDBtype` variable in your `LocalSettings.php` file. You will also need to define other database-related variables. Here's a breakdown for each supported type:

MySQL/MariaDB

```php $wgDBtype = 'mysql'; $wgDBserver = 'localhost'; // Or the IP address of your MySQL server $wgDBname = 'your_database_name'; $wgDBuser = 'your_database_user'; $wgDBpassword = 'your_database_password'; $wgDBport = 3306; // Default port, change if needed ```

Refer to Manual:Database setup for more comprehensive MySQL/MariaDB configuration. Consider using a Database replication setup for larger wikis to improve read performance and provide redundancy.

PostgreSQL

```php $wgDBtype = 'pgsql'; $wgDBserver = 'localhost'; // Or the IP address of your PostgreSQL server $wgDBname = 'your_database_name'; $wgDBuser = 'your_database_user'; $wgDBpassword = 'your_database_password'; $wgDBport = 5432; // Default port, change if needed ```

For PostgreSQL, ensure the `pg_hba.conf` file is correctly configured to allow access from the MediaWiki server. See Manual:PostgreSQL for detailed instructions. Proper Database indexing is essential for PostgreSQL performance.

SQLite

```php $wgDBtype = 'sqlite'; $wgDBserver = '/path/to/your/database.sqlite'; // Full path to the SQLite database file ```

SQLite is simple to set up, but remember its limitations. It is generally unsuitable for wikis with more than a few users. Ensure the web server user has write access to the SQLite database file. See Manual:SQLite for more information.

Database Character Sets and Collations

Choosing the correct character set and collation is vital for supporting multiple languages and ensuring proper data storage. UTF-8 is the recommended character set for MediaWiki.

Database Type Recommended Character Set Recommended Collation
MySQL/MariaDB utf8mb4 utf8mb4_unicode_ci PostgreSQL UTF8 en_US.UTF-8 (or your preferred locale) SQLite UTF-8 NOCASE (optional, for case-insensitive searches)

Incorrect character set settings can lead to data corruption and display issues. Refer to the database documentation for instructions on setting these values. See Manual:Internationalization and localization for wiki specific details.

Troubleshooting $wgDBtype Issues

If you encounter errors related to the database, here are some common troubleshooting steps:

  • **Verify Database Credentials:** Double-check the `$wgDBuser`, `$wgDBpassword`, and `$wgDBname` variables in `LocalSettings.php`.
  • **Check Database Server Status:** Ensure the database server is running and accessible from the MediaWiki server.
  • **Firewall Issues:** Verify that no firewalls are blocking communication between the MediaWiki server and the database server.
  • **Permissions:** Ensure the database user has the necessary permissions to access and modify the database.
  • **Error Logs:** Examine the MediaWiki error logs (`errors/error.log`) and the database server logs for more specific error messages. Also check the Debugging page.
  • **Database Connection Test:** Use a database client (e.g., `mysql` command-line client, `psql`, or a GUI tool) to connect to the database using the same credentials as MediaWiki.
  • **Check `$wgDBprefix`:** Ensure that the `$wgDBprefix` variable is correctly configured if you are using a database prefix.


Further Resources


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.* ⚠️