Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Databases and Redis

phpMyAdmin shows 'Cannot connect: invalid settings' on its Access denied page

ErrorAccess denied!

Short answer

phpMyAdmin prints this text on its config-authentication failure page when it has no MySQL error to quote. Its own checks cause that: an empty password while AllowNoPassword is false, the root user while AllowRoot is false, or an AllowDeny rule that rejects your address. Read those settings in config.inc.php and change the one that applies.

  • Applies to phpMyAdmin 5.2, auth_type config, PHP 8.3
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Open config.inc.php and read the settings that decide whether phpMyAdmin may even try to connect. The three causes below each map to one of these lines.

    grep -n -E "auth_type|\['user'\]|\['password'\]|AllowNoPassword|AllowRoot|AllowDeny" config.inc.php
  2. 2Match what you see, then jump to its fix

    1. 1auth_type is 'config', user is root and password is ''The password is empty and AllowNoPassword is falseFix
    2. 2user is 'root' and the config sets AllowRoot to falseThe user is root and AllowRoot is falseFix
    3. 3The config sets AllowDeny order and rules, and the failure only happens from some machinesAn AllowDeny rule rejects the address you connect fromFix

What does the error look like?

  • Access denied!
  • Cannot connect: invalid settings.
  • Welcome to phpMyAdmin
  • Login without a password is forbidden by configuration (see AllowNoPassword)

Cause 1 of 3

The password is empty and AllowNoPassword is false

1Check

phpMyAdmin refuses a login with an empty password unless AllowNoPassword is true, and its default is false. This check is made by phpMyAdmin's own code, not by MySQL, so there is no MySQL error text to show. Local test stacks often ship root with no password.

grep -n -E "auth_type|\['user'\]|\['password'\]|AllowNoPassword" config.inc.php

2Fix

Give the MySQL account a password and write the same password into config.inc.php. On a throwaway local machine only, you may set AllowNoPassword to true instead. Never do that on a server that others can reach.

$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'the-account-password';
// local test machine only:
// $cfg['Servers'][$i]['AllowNoPassword'] = true;

3Verify

Reload the phpMyAdmin page. The main screen opens and the access denied page does not return. The count below is 0.

curl -s http://localhost/phpmyadmin/index.php | grep -c "Access denied"

Confirmed by docs.phpmyadmin.net

Did this fix it?

Cause 2 of 3

The user is root and AllowRoot is false

1Check

AllowRoot is a shortcut for the AllowDeny rules. With it set to false, phpMyAdmin's own code denies any login with the user name root, so again no MySQL error exists to be shown.

grep -n "AllowRoot" config.inc.php

2Fix

Use a named MySQL account for phpMyAdmin, which is the safer choice. Or, if root access is intended, remove the line or set AllowRoot back to true.

$cfg['Servers'][$i]['user'] = 'pma_admin';
$cfg['Servers'][$i]['password'] = 'the-account-password';
// or, if root is meant to be allowed:
$cfg['Servers'][$i]['AllowRoot'] = true;

3Verify

Reload the page. The main screen opens and the count below is 0.

curl -s http://localhost/phpmyadmin/index.php | grep -c "Access denied"

Confirmed by docs.phpmyadmin.net

Did this fix it?

Cause 3 of 3

An AllowDeny rule rejects the address you connect from

1Check

When an AllowDeny order is set, phpMyAdmin compares the client address with the rules in its own code. With order 'allow,deny' the client is denied unless an allow rule matches and no deny rule does. An empty order switches IP authorization off.

grep -n -A6 "AllowDeny" config.inc.php

2Fix

Add an allow rule for the address you really connect from, or clear the order to switch the rules off if you do not need them.

// 'explicit': the user and address must match an allow rule and no deny rule
$cfg['Servers'][$i]['AllowDeny']['order'] = 'explicit';
$cfg['Servers'][$i]['AllowDeny']['rules'] = ['allow % from 192.0.2.10'];

3Verify

Open phpMyAdmin from the allowed machine and from another one. Only the allowed one gets in, and the allowed one counts 0 below.

curl -s http://localhost/phpmyadmin/index.php | grep -c "Access denied"

Confirmed by docs.phpmyadmin.net

Did this fix it?

How do I stop it coming back?

  • Keep MySQL accounts for phpMyAdmin password-protected from the first day, so AllowNoPassword never has to be switched on.
  • Use cookie authentication on any server that is not your own laptop, so no password sits in config.inc.php.
  • Keep config.inc.php readable only by the web server user and out of version control.
  • After changing an AllowDeny rule, test from one allowed and one denied address.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Databases

Laravel bulk insert fails with 'too many placeholders'

SQLSTATE[HY000]: General error: 1390 Prepared statement contains too many placeholders

Laravel sends one placeholder per value, so one insert of many rows times many columns, or a whereIn with a huge list, creates a statement MySQL refuses.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.