phpmyadmin add multiple hosts

How to Add Multiple Hosts in PHPMyAdmin

PHPMyAdmin is a popular web-based database management tool used by system administrators. In most cases, PHPMyAdmin is used to connect to a single database. But sometimes you may want to connect to multiple databases in PHPMyAdmin. In this article, we will learn how to add multiple hosts in PHPMyAdmin to connect to multiple databases.


How to Add Multiple Hosts in PHPMyAdmin

Here are the steps to add multiple hosts in PHPMyAdmin. For this tutorial, we have assumed that you have PHPMyAdmin running on your system. If you don’t have PHPMyAdmin on your system, here are the steps to install it.


1. Open PHPMyAdmin config file

Open terminal and go to the PHPMyAdmin installation folder. Generally, it is located in /usr/share/phpMyAdmin or /usr/share/phpmyadmin or /etc/phpmyadmin directory. PHPMyAdmin comes with a sample config file. We will copy it for our use.

# cd /usr/share/phpmyadmin
# cp config.sample.inc.php config.inc.php
# vim config.inc.php

Please note, copy the sample config file to the same directory where you find it.


2. Add Database Details

Add the following details at the end of config file. Replace ‘Database Server 2’ and ‘192.168.1.1’ with the name and server IP of your second database.

$i++;
$cfg['Servers'][$i]['verbose'] = 'Database Server 2';
$cfg['Servers'][$i]['host'] = '192.168.1.1';
$cfg['Servers'][$i]['port'] = '';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['AllowNoPassword'] = false;

Save and close the file.


3. Test Changes

Open browser and visit http://localhost/phpmyadmin/

You will see the Login form, with a new dropdown to choose database to connect.

In this article, we have learnt how to add multiple hosts in PHPMyAdmin.

Also read:

Git Compare Difference Between Two Branches
How to Uninstall Ubuntu from Dual Boot
How to Install PHP Composer in Ubuntu
How to List Devices Connected to Network in Ubuntu
How to Fix Bash Command Not Found Error

Leave a Reply

Your email address will not be published.