'Changes to /etc/phpmyadmin/config.inc.php do not have effect

I would like to configure PhpMyAdmin to access only one database through one user.

I tried before to restrict access via .htaccess using this answer from 2013 but it did not work:
phpMyAdmin Block Access to Single Database

I hence tried by adding deny,allow rules as stated in this answer:
How do I restrict access to specific database user accounts in phpMyAdmin?

But it did not work too. I continue to access all users. I have read the documentation and rewrote the lines in config.inc.php as

$cfg['Servers'][$i]['AllowDeny']['order'] = 'deny,allow';
$cfg['Servers'][$i]['AllowDeny']['rules'] = array(
'deny root from all',
'deny user1 from all',
'deny user2 from all',
'allow user3 from all',
);

where user1 and user2 are users to deny, and user2 is user to allow. But I can still access with all users. I hence tried only

$cfg['Servers'][$i]['AllowDeny']['order'] = 'explicit';

that should block access to all users, but I can still access with all users. I hence believe that /etc/phpmyadmin/config.inc.php is being overwritten in some way, since no change has effect, but I do not understand how.

Any idea on where to check?



Solution 1:[1]

Looks like you are allowing access to all users and then again you are trying to restrict some of the users, seems bit confusing.

$cfg['Servers'][$i]['AllowDeny']['order'] = 'deny,allow';

The correct pattern should be deny access to all users and then provide explicit access to the specific user

$cfg['Servers'][$i]['AllowDeny']['order'] = 'explicit';

Please refer the official document https://docs.phpmyadmin.net/en/latest/config.html#cfg_Servers_AllowDeny_order

The correct configuration should be something like this

$cfg['Servers'][$i]['AllowDeny']['order'] = 'explicit';
$cfg['Servers'][$i]['AllowDeny']['rules'] = [
    'allow user3 from all'
];

hope it works for you!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 initvik