Phpmyadmin - Connect to Remote Databases

Phpmyadmin is great, but by default you can only connect to the localhost. By following the steps below you can configure your phpmyadmin to be able to connect to remote hosts without having to enter/remember the usernames/passwords. This is slightly less safe but far more convinient. Less safe because anyone with access to your pc has access to your databases, not to mention passwords are not encrypted in the file.

    sudo gedit /etc/phpmyadmin/
    Find the very last "i++" and replace with the following. (one for each server).
    $cfg['Servers'][$i]['host'] = 'DB host address here (using hostname prevents confusion on login screen)';
    $cfg['Servers'][$i]['port'] = 'set your port here if its not the default (3306)';
    $cfg['Servers'][$i]['socket'] = '';
    $cfg['Servers'][$i]['connect_type'] = 'tcp';
    $cfg['Servers'][$i]['extension'] = '("mysql" or "mysqli" here (mysqli preferred))';
    $cfg['Servers'][$i]['compress'] = FALSE;
    $cfg['Servers'][$i]['auth_type'] = 'config';
    $cfg['Servers'][$i]['user'] = 'username goes here';
    $cfg['Servers'][$i]['password'] = 'password goes here';

    Alternatively you can configure the server in its own array and then add it which makes things easier to understand if adding lots of server:

    Now when you go to phpmyadmin in your browser, you will see a dropdown below the login details from which you can select your server. Please note that if you choose one of these options you do not need to enter the username and password again.


No comments:

Post a Comment