I have phpMyAdmin installed on my local machine. How can I make it connect to an external server?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
To set up an external DB and still use your local DB, you need to edit the config.inc.php file:
The file is roughly set up like this:
What you need to do is duplicate the "your local db setup" by copying and pasting it outside of the
IF
statement I've shown in the code below, and change the host to you external IP. Mine for example is:You can leave the defaults (unless you know you need to change them)
Save and refresh your PHPMYADMIN login page and a new dropdown should appear. You should be good to go.
EDIT: if you want to give the server a name to select at login page, rather than having just the IP address to select, add this to the server setup:
It's good if you have multiple server configs.
using PhpMyAdmin version 4.5.4.1deb2ubuntu2, you can set the variables in
/etc/phpmyadmin/config-db.php
so set
$dbserver
to your server name, e.g.$dbserver='mysql.example.com';
in the config.inc.php, remove all lines with "$cfg['Servers']" , and keep ONLY the "$cfg['Servers'][$i]['host']"
You can use the phpmyadmin setup page (./phpmyadmin/setup) to generate a new config file (
config.inc.php
) for you. This file is found at the root of the phpMyAdmin directory.Just create the config folder as prompted in setup page, add your servers, then click the 'Save' button. This will create a new config file in the config folder you just created.
You now have only to move the
config.inc.php
file to the main phpMyAdmin folder, or just copy the lines concerning the servers if you got some old configuration done already you'd like to keep.Don't forget to delete the config folder afterwards.
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:Just change
localhost
to your server's IP address.Note: you may have to configure the external server to allow remote connections, but I've done this several times on shared hosting so it should be fine.
at version 4.0 or above, we need to create one 'config.inc.php' or rename the 'config.sample.inc.php' to 'config.inc.php';
In my case, I also work with one mysql server for each environment (dev and production):