22

I have two instances of MySql (5.1.73-1-log) running on my server, one on port 3306 (default), one on port 3307. Now, I want to change PhpMyAdmin (3.3.7deb7) to take the second instance, on 3307, instead the default one. Thus, I add the following line to config.inc.php:

    $cfg['Servers'][$i]['port'] = '3307';

Now, though PhpMyAdmin says localhost:3307 (look Screenshot), the databases that it accesses are still those from the instance that runs on the default port.

How do I change the settings in order to make the port change real?

enter image description here

3
  • Is it possible to stop the instance running on 3306 to see what happens in phpMyAdmin? Commented Jan 28, 2015 at 19:40
  • 4
    Relevant.
    – Matt Clark
    Commented Nov 30, 2015 at 23:31
  • I have tried your solution for appending port line $cfg['Servers'][$i]['port'] = '3307'; in config.inc.php, It's functioning properly now. Commented Feb 8, 2017 at 13:08

4 Answers 4

18

You can change this line:

$cfg['Servers'][$i]['host'] = '127.0.0.1';

with this line:

$cfg['Servers'][$i]['host'] = '127.0.0.1:3307';
2
  • 1
    Can you explain why one should do that?
    – Nico Haase
    Commented Apr 12, 2019 at 15:46
  • Because why not
    – Floris
    Commented Nov 30, 2021 at 15:59
5

From the PhpMyAdmin documentation...

If you use localhost as the hostname, MySQL ignores this port number and connects with the socket, so if you want to connect to a port different from the default port, use 127.0.0.1 or the real hostname in $cfg['Servers'][$i]['host'].

3

first open Xamppp Control Panel click on Config Button, at the next page click on Services and Port Settings, at that page you can set all ports for all of your services. also you should change content of Phpmyadmin(config.inc.php) file as below

$cfg['Servers'][$i]['host'] = '127.0.0.1'; 
$cfg['Servers'][$i]['port']= 'your preferred port number';
0

Somehow the statement that connecting to localhost automatically connects through socket rather than port (default 3306) does not seem to be true. I have several servers installed for testing and in my phpMyAdmin page of some of them I see in the topline: "server: localhost" and in others I see "server: localhost:3306". I am guessing that the one without the port number is connected through socket and the others are through IP port 3306. I am still looking how to configure that. It seems obvious to me that the script config.inc.php is not the place to be. I suspect it is some .conf or .cnf or .ini file but I am yet to find which one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.