Search code examples
phpmysqlubuntuphpmyadminaccess-control

How do I restrict access to specific database user accounts in phpMyAdmin?


I'd like to be able to either restrict access to specific database user accounts, or block specific database user accounts from logging in via phpMyAdmin. How can I configure phpMyAdmin to do this?

Specifically, I'm running phpMyAdmin Ubuntu server. I want to know how to configure this at the level of phpMyAdmin itself, and not through the webserver or OS.


Solution

  • To configure phpMyAdmin, you need to find your config.inc.php configuration file. On Ubuntu, this is located in /etc/phpmyadmin. Edit this file.

    Add lines to this file after the block that ends with $i++.

    To deny access to all users by default, and then allow specific users:

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

    To allow access to all users by default, and then deny specific users:

    $cfg['Servers'][$i]['AllowDeny']['order'] = 'deny,allow';
    $cfg['Servers'][$i]['AllowDeny']['rules'] = [
        'deny alex from all'
    ];
    

    You can replace all with patterns to match specific IP addresses or ranges of addresses. See the full documentation at the phpMyAdmin docs.