1

I've got what's probably a very easy question to solve, but I've been stuck on it for a few days now.

I've got 3 servers running in a small network, DNS, HTTP and MySQL. I've got apache2 and PHP5 installed on the HTTP server and MySQL on the MySQL server. I'm trying to install phpmyadmin on the apache2 server but when I try, I get error 2002 (hy000) because /var/lib/mysql/mysql.sock cannot be found, obviously because it isn't installed on that server.

I understand phpmyadmin requires both apache2 and MySQL to run, however, is there a way I can install it on either server while still keeping the servers separated? Ideally on the apache2.

2 Answers 2

2

phpmyadmin should run on the server that has Apache2 and PHP running, but it is able to connect to an external database server. Answer taken from here:

In the config file, change the "host" variable to point to the external server. The config file is called config.inc.php and it will be in the main phpMyAdmin folder. There should be a line like this:

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

Just change localhost to your server's IP address.

6
  • +1, anyway to make this work also the MySQL server should be configured to accept external connections
    – kos
    Apr 10, 2015 at 10:18
  • And what if I have a db on localhost and about 15 other mysql db server?
    – s1mmel
    Apr 10, 2015 at 11:44
  • @s1mmel You can tweak the config file to control multiple servers, as described here.
    – Jos
    Apr 10, 2015 at 11:51
  • I've tried that but having trouble accessing it. I've added GRANT ALL PRIVILEGES ON *.* TO 'httpserver'@'10.0.0.10' IDENTIFIED BY 'PASSWORD'; on the mysql. Also edited /etc/apache2/apache2.conf and added Include /etc/phpmyadmin/apache.conf to the file. Restarted both servers however I still can't access myphpadmin from 10.0.0.40/phpmyadmin. Am I doing something stupid here and missing something out?
    – Xiah
    Apr 10, 2015 at 12:03
  • 1
    dank u well jos :-)
    – s1mmel
    Apr 10, 2015 at 12:19
0

I did manage to fix it. From a basic install of phpmyadmin these are the steps to allow remote connection. If anyone ever needs it

  1. Code out

    /etc/phpmyadmin/confi.inc.php
    $cfg['Servers'][$i]['controluser'] = $dbuser;
    $cfg['Servers'][$i]['controlpass'] = $dbpass;
    
  2. Edit /etc/phpmyadmin/apache.conf

    10.0.0.157 is the machine you want to access the myphpadmin website from

    Order Deny, Allow
    Deny from all
    Allow from 127.0.0.1
    Allow from 10.0.0.157
    
  3. Edit and change /etc/my.cnf

    This allows any machine on the network to connect to the mysql

    bind-address = 0.0.0.0
    
  4. edit /etc/phpmyadmin/config.inc.php put add at the bottom

    $i++;
    $cfg['Servers'][$i]['host'] = '10.0.0.40'; //mysql server IP
    $cfg['Servers'][$i]['user'] = 'username'; (username you want to log into 10.0.0.10/phpmyadmin) (10.0.0.10 is the server that has phpmyadmin on)
    $cfg['Servers'][$i]['password'] = 'password'; //password
    $cfg['Servers'][$i]['auth_type'] = 'config'; // keep it as config`
    

This allows me to log in on my windows machine with the IP 10.0.0.157 in a web browser with 10.0.0.10/phpmyadmin with the username/password combo as above.

When 10.0.0.10/phpmyadmin is accessed, this drop down menu is the addition are given with #4

I can't post the image as I don't have 10 rep points :-( but it will give you a drop down menu of users with the IP address/username set up in #4

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .