I'm setting up MediaWiki on an Ubuntu 18.04 server. After installing the mediawiki package I went to web installer and got to the "Connect to database" step. I'm using the following settings:

  • Database host: localhost
  • Database name: testwiki
  • Database table prefix:
  • Database username: root
  • Database password: fubar

I can SSH into the server, and I used mysqladmin -u root password to set the root password to fubar. I can log into MariaDB using mysql -u root -p and inputting fubar when prompted. I can see that MariaDB is running properly using service mysql status.

However, when I try to progress through the MediaWiki installer, I get the following error:

DB connection error: Access denied for user 'root'@'localhost' (localhost).

Check the host, username and password and try again.

What do I need to change here? The password entered in the web installer matches the root password used to log into the database.

  • A very late comment: I am not very experienced and had a similar problem. I solved it by creating an ordinary user account for the database and assigning the access to MediaWiki through the configuration page. I spent hours googling a solution to access through root account, the divergent answers indicated to me that it is not a straightforward issue.
    – gamebm
    Jul 20, 2021 at 2:03

2 Answers 2


For newer mediawiki versions, there are some pitfalls that breaks the mysql connection. Some attempts to fix are:

  1. Insert the port number on Database Host:
$wgDBserver = "localhost:3306";
  1. On some old LocalSettings.php, there are active configurations for PostgreSQL besides the Mysql config. Erase or comment it.
# Postgres specific settings
# $wgDBport           = "5432";
# $wgDBmwschema       = "mediawiki";
# $wgDBts2schema      = "public";

Seems you are required to create the testwiki database manually, as well as a testadmin user with its own password, then manually give testadmin permissions on testwiki. Doing that solved the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.