Connecting phpmyadmin to separate MySQL server
Solution 1
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
-
Code out
/etc/phpmyadmin/confi.inc.php $cfg['Servers'][$i]['controluser'] = $dbuser; $cfg['Servers'][$i]['controlpass'] = $dbpass;
-
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
-
Edit and change
/etc/my.cnf
This allows any machine on the network to connect to the mysql
bind-address = 0.0.0.0
-
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
Solution 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.
Related videos on Youtube
Xiah
Updated on September 18, 2022Comments
-
Xiah over 1 year
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.
-
kos about 9 years+1, anyway to make this work also the
MySQL
server should be configured to accept external connections -
s1mmel about 9 yearsAnd what if I have a db on localhost and about 15 other mysql db server?
-
Jos about 9 years@s1mmel You can tweak the config file to control multiple servers, as described here.
-
Xiah about 9 yearsI'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 addedInclude /etc/phpmyadmin/apache.conf
to the file. Restarted both servers however I still can't access myphpadmin from10.0.0.40/phpmyadmin
. Am I doing something stupid here and missing something out? -
Jos about 9 yearsEnabling MySQL to allow access from the network is a different matter, as @kos already noticed. Go through the steps here and it should work.
-
s1mmel about 9 yearsdank u well jos :-)