How to secure phpMyAdmin

后端 未结 9 713
清歌不尽
清歌不尽 2020-12-02 04:40

I have noticed that there are strange requests to my website trying to find phpmyadmin, like

/phpmyadmin/
/pma/

etc.

Now I have ins

9条回答
  •  清歌不尽
    2020-12-02 04:51

    In newer versions of phpMyAdmin access permissions for user-names + ip-addresses can be set up inside the phpMyAdmin's config.inc.php file. This is a much better and more robust method of restricting access (over hard-coding URLs and IP addresses into Apache's httpd.conf).

    Here is a full example of how to switch to white-listing all users (no one outside this list will be allowed access), and also how to restrict user root to the local system and network only.

    $cfg['Servers'][$i]['AllowDeny']['order'] = 'deny,allow';
    $cfg['Servers'][$i]['AllowDeny']['rules'] = array(
        'deny % from all', // deny everyone by default, then -
    
        'allow % from 127.0.0.1', // allow all local users
        'allow % from ::1',
    
        //'allow % from SERVER_ADDRESS', // allow all from server IP
    
        // allow user:root access from these locations (local network)
        'allow root from localhost',
        'allow root from 127.0.0.1',
        'allow root from 10.0.0.0/8',
        'allow root from 172.16.0.0/12',
        'allow root from 192.168.0.0/16',
    
        'allow root from ::1',
    
        // add more usernames and their IP (or IP ranges) here -    
        );
    

    Source: How to Install and Secure phpMyAdmin on localhost for Windows

    This gives you much more fine-grained access restrictions than Apache's URL permissions or an .htaccess file can provide, at the MySQL user name level.

    Make sure that the user you are login in with, has its MySQL Host: field set to 127.0.0.1 or ::1, as phpMyAdmin and MySQL are on the same system.

提交回复
热议问题