phpMyAdmin shows 'Cannot connect: invalid settings' on its Access denied page
Access 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.
Fix it fast
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.php2Match what you see, then jump to its fix
- 1
auth_type is 'config', user is root and password is ''The password is empty and AllowNoPassword is falseFix - 2
user is 'root' and the config sets AllowRoot to falseThe user is root and AllowRoot is falseFix - 3
The config sets AllowDeny order and rules, and the failure only happens from some machinesAn AllowDeny rule rejects the address you connect fromFix
- 1
What does the error look like?
Access denied!Cannot connect: invalid settings.Welcome to phpMyAdminLogin 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.php2Fix
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
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.php2Fix
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
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.php2Fix
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
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
phpMyAdmin: Access denied for user 'root'@'localhost'
#1045 - Access denied for user 'root'@'localhost' (using password: YES)
MySQL refused the root login.
4 causes, each with a fixDatabases
A container cannot resolve the name of its database container
php_network_getaddresses: getaddrinfo failed
127.0.0.11 is Docker's own DNS server for custom networks.
3 causes, each with a fixDatabases
elasticsearch-php says it found no alive nodes in the cluster
No alive nodes found in your cluster
The client tried every host in its list and none answered in a usable way.
3 causes, each with a fixDatabases
PHP cannot connect to SQL Server through FreeTDS
Connection Refused
FreeTDS prints this when it cannot open a session with the server name you gave it.
3 causes, each with a fixDatabases
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 fixDatabases
Laravel query fails: conversion from one collation into another is impossible
SQLSTATE[HY000]: General error: 3988 Conversion from collation utf8_unicode_ci into utf8mb4_0900_ai_ci impossible for parameter
MySQL is comparing or binding a value whose character set cannot be converted into the one on the other side.
3 causes, each with a fix