installation — phpmyadmin 5.2.0 documentation-尊龙登录

phpmyadmin does not apply any special security methods to the mysql database server. it is still the system administrator’s job to grant permissions on the mysql databases properly. phpmyadmin’s users page can be used for this.

linux distributions

phpmyadmin is included in most linux distributions. it is recommended to use distribution packages when possible - they usually provide integration to your distribution and you will automatically get security updates from your distribution.

debian and ubuntu

most debian and ubuntu versions include a phpmyadmin package, but be aware that the configuration file is maintained in /etc/phpmyadmin and may differ in some ways from the official phpmyadmin documentation. specifically, it does:

more specific details about installing debian or ubuntu packages are available .

see also

more information can be found in (it is installed as /usr/share/doc/phpmyadmin/readme.debian with the package).


opensuse already comes with phpmyadmin package, just install packages from the .


gentoo ships the phpmyadmin package, both in a near-stock configuration as well as in a webapp-config configuration. use emerge dev-db/phpmyadmin to install.


mandriva ships the phpmyadmin package in their contrib branch and can be installed via the usual control center.


fedora ships the phpmyadmin package, but be aware that the configuration file is maintained in /etc/phpmyadmin/ and may differ in some ways from the official phpmyadmin documentation.

red hat enterprise linux

red hat enterprise linux itself and thus derivatives like centos don’t ship phpmyadmin, but the fedora-driven repository is doing so, if it’s . but be aware that the configuration file is maintained in /etc/phpmyadmin/ and may differ in some ways from the official phpmyadmin documentation.

installing on windows

the easiest way to get phpmyadmin on windows is using third party products which include phpmyadmin together with a database and web server such as .

you can find more of such options at .

installing from git

in order to install from git, you’ll need a few supporting applications:

  • to download the source, or you can download the most recent source directly from

  • (version 10 or higher)

you can clone current phpmyadmin source from

git clone

additionally you need to install dependencies using :

composer update

if you do not intend to develop, you can skip the installation of developer tools by invoking:

composer update --no-dev

finally, you’ll need to use to install some javascript dependencies:

yarn install --production

installing using composer

you can install phpmyadmin using the , since 4.7.0 the releases are automatically mirrored to the default repository.


the content of the composer repository is automatically generated separately from the releases, so the content doesn’t have to be 100% same as when you download the tarball. there should be no functional differences though.

to install phpmyadmin simply run:

composer create-project phpmyadmin/phpmyadmin

alternatively you can use our own composer repository, which contains the release tarballs and is available at <>:

composer create-project phpmyadmin/phpmyadmin --repository-url= --no-dev

installing using docker

phpmyadmin comes with a , which you can easily deploy. you can download it using:

docker pull phpmyadmin

the phpmyadmin server will listen on port 80. it supports several ways of configuring the link to the database server, either by docker’s link feature by linking your database container to db for phpmyadmin (by specifying --link your_db_host:db) or by environment variables (in this case it’s up to you to set up networking in docker to allow the phpmyadmin container to access the database container over the network).

docker environment variables

you can configure several phpmyadmin features using environment variables:


allows you to enter a database server hostname on login form.


hostname or ip address of the database server to use.


comma-separated hostnames or ip addresses of the database servers to use.


used only if pma_host is empty.


verbose name of the database server.


comma-separated verbose name of the database servers.


used only if pma_verbose is empty.


user name to use for config authentication mode.


password to use for config authentication mode.


port of the database server to use.


comma-separated ports of the database server to use.


used only if pma_port is empty.


the fully-qualified path ( where the reverse proxy makes phpmyadmin available.


if defined, this option will hide the php version (expose_php = off). set to any value (such as hide_php_version=true).


if set, this option will override the default value for apache and php-fpm (this will change upload_max_filesize and post_max_size values).


format as [0-9 ](k,m,g) default value is 2048k


if set, this option will override the default with the base64 decoded contents of the variable.


if set, this option will override the default with the base64 decoded contents of the variable.

by default, cookie authentication mode is used, but if pma_user and pma_password are set, it is switched to config authentication mode.


the credentials you need to log in are stored in the mysql server, in case of docker image, there are various ways to set it (for example mysql_root_password when starting the mysql container). please check documentation for or .

customizing configuration

additionally configuration can be tweaked by /etc/phpmyadmin/ if this file exists, it will be loaded after configuration is generated from above environment variables, so you can override any configuration variable. this configuration can be added as a volume when invoking docker using -v /some/local/directory/ parameters.

note that the supplied configuration file is applied after docker environment variables, but you can override any of the values.

for example to change the default behavior of csv export you can use the following configuration file:

$cfg['export']['csv_columns'] = true;

you can also use it to define server configuration instead of using the environment variables listed in docker environment variables:

/* override servers array */
$cfg['servers'] = [
    1 => [
        'auth_type' => 'cookie',
        'host' => 'mydb1',
        'port' => 3306,
        'verbose' => 'verbose name 1',
    2 => [
        'auth_type' => 'cookie',
        'host' => 'mydb2',
        'port' => 3306,
        'verbose' => 'verbose name 2',

see also

see configuration for detailed description of configuration options.

docker volumes

you can use the following volumes to customize image behavior:


can be used for additional settings, see the previous chapter for more details.


directory where php sessions are stored. you might want to share this for example when using signon authentication mode.


directory where phpmyadmin looks for themes. by default only those shipped with phpmyadmin are included, but you can include additional phpmyadmin themes (see custom themes) by using docker volumes.

docker examples

to connect phpmyadmin to a given server use:

docker run --name myadmin -d -e pma_host=dbhost -p 8080:80 phpmyadmin/phpmyadmin

to connect phpmyadmin to more servers use:

docker run --name myadmin -d -e pma_hosts=dbhost1,dbhost2,dbhost3 -p 8080:80 phpmyadmin/phpmyadmin

to use arbitrary server option:

docker run --name myadmin -d --link mysql_db_server:db -p 8080:80 -e pma_arbitrary=1 phpmyadmin/phpmyadmin

you can also link the database container using docker:

docker run --name phpmyadmin -d --link mysql_db_server:db -p 8080:80 phpmyadmin/phpmyadmin

running with additional configuration:

docker run --name phpmyadmin -d --link mysql_db_server:db -p 8080:80 -v /some/local/directory/ phpmyadmin/phpmyadmin

running with additional themes:

docker run --name phpmyadmin -d --link mysql_db_server:db -p 8080:80 -v /custom/phpmyadmin/theme/:/www/themes/theme/ phpmyadmin/phpmyadmin

using docker-compose

alternatively, you can also use docker-compose with the docker-compose.yml from <>. this will run phpmyadmin with an arbitrary server - allowing you to specify mysql/mariadb server on the login page.

docker-compose up -d

customizing configuration file using docker-compose

you can use an external file to customize phpmyadmin configuration and pass it using the volumes directive:

    image: phpmyadmin/phpmyadmin
    container_name: phpmyadmin
     - pma_arbitrary=1
    restart: always
     - 8080:80
     - /sessions
     - ~/docker/phpmyadmin/
     - /custom/phpmyadmin/theme/:/www/themes/theme/

running behind haproxy in a subdirectory

when you want to expose phpmyadmin running in a docker container in a subdirectory, you need to rewrite the request path in the server proxying the requests.

for example, using haproxy it can be done as:

frontend http
    bind *:80
    option forwardfor
    option http-server-close
    ### network restriction
    acl localnet  src
    # /phpmyadmin
    acl phpmyadmin  path_dir /phpmyadmin
    use_backend phpmyadmin if phpmyadmin localnet
backend phpmyadmin
    mode http
    reqirep  ^(get|post|head)\ /phpmyadmin/(.*)     \1\ /\2
    # phpmyadmin container ip
    server localhost

when using traefik, something like following should work:

defaultentrypoints = ["http"]
  address = ":80"
      regex = "(http:\\/\\/[^\\/] \\/([^\\?\\.] )[^\\/])$"
      replacement = "$1/"
   backend = "myadmin"
   passhostheader = true

you then should specify pma_absolute_uri in the docker-compose configuration:

version: '2'
    restart: always
    image: phpmyadmin/phpmyadmin
    container_name: phpmyadmin
    hostname: phpmyadmin
      - 8000:80
      - pma_hosts=,,,
      - pma_verboses=production-db1,production-db2,dev-db1,dev-db2
      - pma_user=root
      - pma_password=
      - pma_absolute_uri=

ibm cloud

one of our users has created a helpful guide for installing phpmyadmin on the .

quick install

  1. choose an appropriate distribution kit from the downloads page. some kits contain only the english messages, others contain all languages. we’ll assume you chose a kit whose name looks like phpmyadmin-x.x.x -all-languages.tar.gz.

  2. ensure you have downloaded a genuine archive, see verifying phpmyadmin releases.

  3. untar or unzip the distribution (be sure to unzip the subdirectories): tar -xzvf phpmyadmin_x.x.x-all-languages.tar.gz in your webserver’s document root. if you don’t have direct access to your document root, put the files in a directory on your local machine, and, after step 4, transfer the directory on your web server using, for example, ftp.

  4. ensure that all the scripts have the appropriate owner (if php is running in safe mode, having some scripts with an owner different from the owner of other scripts will be a problem). see 4.2 what’s the preferred way of making phpmyadmin secure against evil access? and 1.26 i just installed phpmyadmin in my document root of iis but i get the error “no input file specified” when trying to run phpmyadmin. for suggestions.

  5. now you must configure your installation. there are two methods that can be used. traditionally, users have hand-edited a copy of, but now a wizard-style setup script is provided for those who prefer a graphical installation. creating a is still a quick way to get started and needed for some advanced features.

manually creating the file

to manually create the file, simply use your text editor to create the file (you can copy to get a minimal configuration file) in the main (top-level) phpmyadmin directory (the one that contains index.php). phpmyadmin first loads the default configuration values and then overrides those values with anything found in if the default value is okay for a particular setting, there is no need to include it in you’ll probably need only a few directives to get going; a simple configuration may look like this:

// use here a value of your choice at least 32 chars long
$cfg['blowfish_secret'] = '1{dd0`;
$cfg['servers'][$i]['auth_type']     = 'cookie';
// if you insist on "root" having no password:
// $cfg['servers'][$i]['allownopassword'] = true;

or, if you prefer to not be prompted every time you log in:

$cfg['servers'][$i]['user']          = 'root';
$cfg['servers'][$i]['password']      = 'changeme'; // use here your password
$cfg['servers'][$i]['auth_type']     = 'config';


storing passwords in the configuration is insecure as anybody can then manipulate your database.

for a full explanation of possible configuration values, see the configuration of this document.

using the setup script

instead of manually editing, you can use phpmyadmin’s setup feature. the file can be generated using the setup and you can download it for upload to the server.

next, open your browser and visit the location where you installed phpmyadmin, with the /setup suffix. the changes are not saved to the server, you need to use the download button to save them to your computer and then upload to the server.

now the file is ready to be used. you can choose to review or edit the file with your favorite editor, if you prefer to set some advanced options that the setup script does not provide.

  1. if you are using the auth_type “config”, it is suggested that you protect the phpmyadmin installation directory because using config does not require a user to enter a password to access the phpmyadmin installation. use of an alternate authentication method is recommended, for example with http–auth in a .htaccess file or switch to using auth_type cookie or http. see the isps, multi-user installations for additional information, especially 4.4 phpmyadmin always gives “access denied” when using http authentication..

  2. open the main phpmyadmin directory in your browser. phpmyadmin should now display a welcome screen and your databases, or a login dialog if using http or cookie authentication mode.

setup script on debian, ubuntu and derivatives

debian and ubuntu have changed the way in which the setup script is enabled and disabled, in a way that single command has to be executed for either of these.

to allow editing configuration invoke:


to block editing configuration invoke:


setup script on opensuse

some opensuse releases do not include setup script in the package. in case you want to generate configuration on these you can either download original package from <> or use setup script on our demo server: <>.

verifying phpmyadmin releases

since july 2015 all phpmyadmin releases are cryptographically signed by the releasing developer, who through january 2016 was marc delisle. his key id is 0xfefc65d181af644a, his pgp fingerprint is:

436f f188 4b1a 0c3f dcbf 0d79 fefc 65d1 81af 644a

and you can get more identification information from <>.

beginning in january 2016, the release manager is isaac bennetch. his key id is 0xce752f178259bd92, and his pgp fingerprint is:

3d06 a59e ce73 0eb7 1b51 1c17 ce75 2f17 8259 bd92

and you can get more identification information from <>.

some additional downloads (for example themes) might be signed by michal čihař. his key id is 0x9c27b31342b7511d, and his pgp fingerprint is:

63cb 1df1 ef12 cf2a c0ee 5a32 9c27 b313 42b7 511d

and you can get more identification information from <>.

you should verify that the signature matches the archive you have downloaded. this way you can be sure that you are using the same code that was released. you should also verify the date of the signature to make sure that you downloaded the latest version.

each archive is accompanied by .asc files which contain the pgp signature for it. once you have both of them in the same folder, you can verify the signature:

$ gpg --verify
gpg: signature made fri 29 jan 2016 08:59:37 am est using rsa key id 8259bd92
gpg: can't check signature: public key not found

as you can see gpg complains that it does not know the public key. at this point, you should do one of the following steps:

  • download the keyring from , then import it with:

$ gpg --import phpmyadmin.keyring
  • download and import the key from one of the key servers:

$ gpg --keyserver hkp:// --recv-keys 3d06a59ece730eb71b511c17ce752f178259bd92
gpg: requesting key 8259bd92 from hkp server
gpg: key 8259bd92: public key "isaac bennetch " imported
gpg: no ultimately trusted keys found
gpg: total number processed: 1
gpg:               imported: 1  (rsa: 1)

this will improve the situation a bit - at this point, you can verify that the signature from the given key is correct but you still can not trust the name used in the key:

$ gpg --verify
gpg: signature made fri 29 jan 2016 08:59:37 am est using rsa key id 8259bd92
gpg: good signature from "isaac bennetch "
gpg:                 aka "isaac bennetch "
gpg: warning: this key is not certified with a trusted signature!
gpg:          there is no indication that the signature belongs to the owner.
primary key fingerprint: 3d06 a59e ce73 0eb7 1b51  1c17 ce75 2f17 8259 bd92

the problem here is that anybody could issue the key with this name. you need to ensure that the key is actually owned by the mentioned person. the gnu privacy handbook covers this topic in the chapter . the most reliable method is to meet the developer in person and exchange key fingerprints, however, you can also rely on the web of trust. this way you can trust the key transitively though signatures of others, who have met the developer in person.

once the key is trusted, the warning will not occur:

$ gpg --verify
gpg: signature made fri 29 jan 2016 08:59:37 am est using rsa key id 8259bd92
gpg: good signature from "isaac bennetch " [full]

should the signature be invalid (the archive has been changed), you would get a clear error regardless of the fact that the key is trusted or not:

$ gpg --verify
gpg: signature made fri 29 jan 2016 08:59:37 am est using rsa key id 8259bd92
gpg: bad signature from "isaac bennetch " [unknown]

phpmyadmin configuration storage

changed in version 3.4.0: prior to phpmyadmin 3.4.0 this was called linked tables infrastructure, but the name was changed due to the extended scope of the storage.

for a whole set of additional features (bookmarks, comments, sql-history, tracking mechanism, pdf-generation, transformations, relations etc.) you need to create a set of special tables. those tables can be located in your own database, or in a central database for a multi-user installation (this database would then be accessed by the controluser, so no other user should have rights to it).

zero configuration

in many cases, this database structure can be automatically created and configured. this is called “zero configuration” mode and can be particularly useful in shared hosting situations. “zeroconf” mode is on by default, to disable set $cfg['zeroconf'] to false.

the following three scenarios are covered by the zero configuration mode:

  • when entering a database where the configuration storage tables are not present, phpmyadmin offers to create them from the operations tab.

  • when entering a database where the tables do already exist, the software automatically detects this and begins using them. this is the most common situation; after the tables are initially created automatically they are continually used without disturbing the user; this is also most useful on shared hosting where the user is not able to edit and usually the user only has access to one database.

  • when having access to multiple databases, if the user first enters the database containing the configuration storage tables then switches to another database, phpmyadmin continues to use the tables from the first database; the user is not prompted to create more tables in the new database.

manual configuration

please look at your ./sql/ directory, where you should find a file called create_tables.sql. (if you are using a windows server, pay special attention to 1.23 i’m running mysql on a win32 machine. each time i create a new table the table and column names are changed to lowercase!).

if you already had this infrastructure and:

  • upgraded to mysql 4.1.2 or newer, please use sql/upgrade_tables_mysql_4_1_2 .sql.

  • upgraded to phpmyadmin 4.3.0 or newer from 2.5.0 or newer (<= 4.2.x), please use sql/upgrade_column_info_4_3_0 .sql.

  • upgraded to phpmyadmin 4.7.0 or newer from 4.3.0 or newer, please use sql/upgrade_tables_4_7_0 .sql.

and then create new tables by importing sql/create_tables.sql.

you can use your phpmyadmin to create the tables for you. please be aware that you may need special (administrator) privileges to create the database and tables, and that the script may need some tuning, depending on the database name.

after having imported the sql/create_tables.sql file, you should specify the table names in your file. the directives used for that can be found in the configuration.

you will also need to have a controluser ($cfg['servers'][$i]['controluser'] and $cfg['servers'][$i]['controlpass'] settings) with the proper rights to those tables. for example you can create it using following statement:

and for any mariadb version:

create user 'pma'@'localhost' identified via mysql_native_password using 'pmapass';
grant select, insert, update, delete on ``.* to 'pma'@'localhost';

for mysql 8.0 and newer:

create user 'pma'@'localhost' identified with caching_sha2_password by 'pmapass';
grant select, insert, update, delete on <pma_db>.* to 'pma'@'localhost';

for mysql older than 8.0:

create user 'pma'@'localhost' identified with mysql_native_password as 'pmapass';
grant select, insert, update, delete on <pma_db>.* to 'pma'@'localhost';

note that mysql installations with php older than 7.4 and mysql newer than 8.0 may require using the mysql_native_password authentication as a workaround, see 1.45 i get an error message about unknown authentication method caching_sha2_password when trying to log in for details.

upgrading from an older version


never extract the new version over an existing installation of phpmyadmin, always first remove the old files keeping just the configuration.

this way, you will not leave any old or outdated files in the directory, which can have severe security implications or can cause various breakages.

simply copy from your previous installation into the newly unpacked one. configuration files from old versions may require some tweaking as some options have been changed or removed. for compatibility with php 5.3 and later, remove a set_magic_quotes_runtime(0); statement that you might find near the end of your configuration file.

the complete upgrade can be performed in a few simple steps:

  1. download the latest phpmyadmin version from <>.

  2. rename existing phpmyadmin folder (for example to phpmyadmin-old).

  3. unpack freshly downloaded phpmyadmin to the desired location (for example phpmyadmin).

  4. copy` from old location (phpmyadmin-old) to the new one (phpmyadmin).

  5. test that everything works properly.

  6. remove backup of a previous version (phpmyadmin-old).

if you have upgraded your mysql server from a version previous to 4.1.2 to version 5.x or newer and if you use the phpmyadmin configuration storage, you should run the sql script found in sql/upgrade_tables_mysql_4_1_2 .sql.

if you have upgraded your phpmyadmin to 4.3.0 or newer from 2.5.0 or newer (<= 4.2.x) and if you use the phpmyadmin configuration storage, you should run the sql script found in sql/upgrade_column_info_4_3_0 .sql.

do not forget to clear the browser cache and to empty the old session by logging out and logging in again.

using authentication modes

http and cookie authentication modes are recommended in a multi-user environment where you want to give users access to their own database and don’t want them to play around with others. nevertheless, be aware that ms internet explorer seems to be really buggy about cookies, at least till version 6. even in a single-user environment, you might prefer to use http or cookie mode so that your user/password pair are not in clear in the configuration file.

http and cookie authentication modes are more secure: the mysql login information does not need to be set in the phpmyadmin configuration file (except possibly for the $cfg['servers'][$i]['controluser']). however, keep in mind that the password travels in plain text unless you are using the https protocol. in cookie mode, the password is stored, encrypted with the aes algorithm, in a temporary cookie.

then each of the true users should be granted a set of privileges on a set of particular databases. normally you shouldn’t give global privileges to an ordinary user unless you understand the impact of those privileges (for example, you are creating a superuser). for example, to grant the user real_user with all privileges on the database user_base:

grant all privileges on user_base.* to 'real_user'@localhost identified by 'real_password';

what the user may now do is controlled entirely by the mysql user management system. with http or cookie authentication mode, you don’t need to fill the user/password fields inside the $cfg['servers'].

http authentication mode


there is no way to do proper logout in http authentication, most browsers will remember credentials until there is no different successful authentication. because of this, this method has a limitation that you can not login with the same user after logout.

signon authentication mode

the very basic example of saving credentials in a session is available as examples/signon.php:

 * single signon for phpmyadmin
 * this is just example how to use session based single signon with
 * phpmyadmin, it is not intended to be perfect code and look, only
 * shows how you can integrate this functionality in your application.
/* use cookies for session */
ini_set('session.use_cookies', 'true');
/* change this to true if using phpmyadmin over https */
$secure_cookie = false;
/* need to have cookie visible from parent directory */
session_set_cookie_params(0, '/', '', $secure_cookie, true);
/* create signon session */
$session_name = 'signonsession';
// uncomment and change the following line to match your $cfg['sessionsavepath']
/* was data posted? */
if (isset($_post['user'])) {
    /* store there credentials */
    $_session['pma_single_signon_user'] = $_post['user'];
    $_session['pma_single_signon_password'] = $_post['password'];
    $_session['pma_single_signon_host'] = $_post['host'];
    $_session['pma_single_signon_port'] = $_post['port'];
    /* update another field of server configuration */
    $_session['pma_single_signon_cfgupdate'] = ['verbose' => 'signon test'];
    $_session['pma_single_signon_hmac_secret'] = hash('sha1', uniqid(strval(random_int(0, mt_getrandmax())), true));
    $id = session_id();
    /* close that session */
    /* redirect to phpmyadmin (should use absolute url here!) */
    header('location: ../index.php');
} else {
    /* show simple form */
    header('content-type: text/html; charset=utf-8');
    echo '' . "\n";
    echo '

phpmyadmin single signon example
    if (isset($_session['pma_single_signon_error_message'])) {
        echo '

'; echo $_session['pma_single_signon_error_message']; echo '

; } echo '
host: (will use the one from by default)
port: (will use the one from by default)
'; }

alternatively, you can also use this way to integrate with openid as shown in examples/openid.php:

 * single signon for phpmyadmin using openid
 * this is just example how to use single signon with phpmyadmin, it is
 * not intended to be perfect code and look, only shows how you can
 * integrate this functionality in your application.
 * it uses openid pear package, see
 * user first authenticates using openid and based on content of $auth_map
 * the login information is passed to phpmyadmin in session data.
if (false === @include_once 'openid/relyingparty.php') {
/* change this to true if using phpmyadmin over https */
$secure_cookie = false;
 * map of authenticated users to mysql user/password pairs.
$auth_map = [
    '' => [
        'user' => 'root',
        'password' => '',
// phpcs:disable psr1.files.sideeffects,squiz.functions.globalfunction
 * simple function to show html page with given content.
 * @param string $contents content to include in page
function show_page($contents): void
    header('content-type: text/html; charset=utf-8');
    echo '' . "\n";
    echo '

phpmyadmin openid signon example
    if (isset($_session['pma_single_signon_error_message'])) {
        echo '

' . $_session['pma_single_signon_message'] . '

; unset($_session['pma_single_signon_message']); } echo $contents; echo ''; } /** * display error and exit * * @param exception $e exception object */ function die_error($e): void { $contents = "
\n"; $contents .= '
' . htmlspecialchars($e->getmessage()) . "
\n"; $contents .= "
; show_page($contents); exit; } // phpcs:enable /* need to have cookie visible from parent directory */ session_set_cookie_params(0, '/', '', $secure_cookie, true); /* create signon session */ $session_name = 'signonsession'; session_name($session_name); @session_start(); // determine realm and return_to $base = 'http'; if (isset($_server['https']) && $_server['https'] === 'on') { $base .= 's'; } $base .= '://' . $_server['server_name'] . ':' . $_server['server_port']; $realm = $base . '/'; $returnto = $base . dirname($_server['php_self']); if ($returnto[strlen($returnto) - 1] !== '/') { $returnto .= '/'; } $returnto .= 'openid.php'; /* display form */ if ((! count($_get) && ! count($_post)) || isset($_get['phpmyadmin'])) { /* show simple form */ $content = '
; show_page($content); exit; } /* grab identifier */ $identifier = null; if (isset($_post['identifier']) && is_string($_post['identifier'])) { $identifier = $_post['identifier']; } elseif (isset($_session['identifier']) && is_string($_session['identifier'])) { $identifier = $_session['identifier']; } /* create openid object */ try { $o = new openid_relyingparty($returnto, $realm, $identifier); } catch (throwable $e) { die_error($e); } /* redirect to openid provider */ if (isset($_post['start'])) { try { $authrequest = $o->prepare(); } catch (throwable $e) { die_error($e); } $url = $authrequest->getauthorizeurl(); header('location: ' . $url); exit; } /* grab query string */ if (! count($_post)) { [, $querystring] = explode('?', $_server['request_uri']); } else { // fetch the raw query body $querystring = file_get_contents('php://input'); } /* check reply */ try { $message = new openid_message($querystring, openid_message::format_http); } catch (throwable $e) { die_error($e); } $id = $message->get('openid.claimed_id'); if (empty($id) || ! isset($auth_map[$id])) { show_page('

user not allowed!

); exit; } $_session['pma_single_signon_user'] = $auth_map[$id]['user']; $_session['pma_single_signon_password'] = $auth_map[$id]['password']; $_session['pma_single_signon_hmac_secret'] = hash('sha1', uniqid(strval(random_int(0, mt_getrandmax())), true)); session_write_close(); /* redirect to phpmyadmin (should use absolute url here!) */ header('location: ../index.php');

if you intend to pass the credentials using some other means than, you have to implement wrapper in php to get that data and set it to $cfg['servers'][$i]['signonscript']. there is a very minimal example in examples/signon-script.php:

 * single signon for phpmyadmin
 * this is just example how to use script based single signon with
 * phpmyadmin, it is not intended to be perfect code and look, only
 * shows how you can integrate this functionality in your application.
// phpcs:disable squiz.functions.globalfunction
 * this function returns username and password.
 * it can optionally use configured username as parameter.
 * @param string $user user name
 * @return array
function get_login_credentials($user)
    /* optionally we can use passed username */
    if (! empty($user)) {
        return [
    /* here we would retrieve the credentials */
    return [

config authentication mode

  • this mode is sometimes the less secure one because it requires you to fill the $cfg['servers'][$i]['user'] and $cfg['servers'][$i]['password'] fields (and as a result, anyone who can read your can discover your username and password).

  • in the isps, multi-user installations section, there is an entry explaining how to protect your configuration file.

  • for additional security in this mode, you may wish to consider the host authentication $cfg['servers'][$i]['allowdeny']['order'] and $cfg['servers'][$i]['allowdeny']['rules'] configuration directives.

  • unlike cookie and http, does not require a user to log in when first loading the phpmyadmin site. this is by design but could allow any user to access your installation. use of some restriction method is suggested, perhaps a .htaccess file with the http-auth directive or disallowing incoming http requests at one’s router or firewall will suffice (both of which are beyond the scope of this manual but easily searchable with google).

securing your phpmyadmin installation

the phpmyadmin team tries hard to make the application secure, however there are always ways to make your installation more secure:

  • follow our and upgrade phpmyadmin whenever new vulnerability is published.

  • serve phpmyadmin on https only. preferably, you should use hsts as well, so that you’re protected from protocol downgrade attacks.

  • ensure your php setup follows recommendations for production sites, for example should be disabled.

  • remove the test directory from phpmyadmin, unless you are developing and need a test suite.

  • remove the setup directory from phpmyadmin, you will probably not use it after the initial setup.

  • properly choose an authentication method - cookie authentication mode is probably the best choice for shared hosting.

  • deny access to auxiliary files in ./libraries/ or ./templates/ subfolders in your webserver configuration. such configuration prevents from possible path exposure and cross side scripting vulnerabilities that might happen to be found in that code. for the apache webserver, this is often accomplished with a .htaccess file in those directories.

  • deny access to temporary files, see $cfg['tempdir'] (if that is placed inside your web root, see also web server upload/save/import directories.

  • it is generally a good idea to protect a public phpmyadmin installation against access by robots as they usually can not do anything good there. you can do this using robots.txt file in the root of your webserver or limit access by web server configuration, see 1.42 how can i prevent robots from accessing phpmyadmin?.

  • in case you don’t want all mysql users to be able to access phpmyadmin, you can use $cfg['servers'][$i]['allowdeny']['rules'] to limit them or $cfg['servers'][$i]['allowroot'] to deny root user access.

  • enable two-factor authentication for your account.

  • consider hiding phpmyadmin behind an authentication proxy, so that users need to authenticate prior to providing mysql credentials to phpmyadmin. you can achieve this by configuring your web server to request http authentication. for example in apache this can be done with:

    authtype basic
    authname "restricted access"
    authuserfile /usr/share/phpmyadmin/passwd
    require valid-user

    once you have changed the configuration, you need to create a list of users which can authenticate. this can be done using the htpasswd utility:

    htpasswd -c /usr/share/phpmyadmin/passwd username
  • if you are afraid of automated attacks, enabling captcha by $cfg['captchaloginpublickey'] and $cfg['captchaloginprivatekey'] might be an option.

  • failed login attempts are logged to syslog (if available, see $cfg['authlog']). this can allow using a tool such as fail2ban to block brute-force attempts. note that the log file used by syslog is not the same as the apache error or access log files.

  • in case you’re running phpmyadmin together with other php applications, it is generally advised to use separate session storage for phpmyadmin to avoid possible session-based attacks against it. you can use $cfg['sessionsavepath'] to achieve this.

using ssl for connection to database server

it is recommended to use ssl when connecting to remote database server. there are several configuration options involved in the ssl setup:


defines whether to use ssl at all. if you enable only this, the connection will be encrypted, but there is not authentication of the connection - you can not verify that you are talking to the right server.

$cfg['servers'][$i]['ssl_key'] and $cfg['servers'][$i]['ssl_cert']

this is used for authentication of client to the server.

$cfg['servers'][$i]['ssl_ca'] and $cfg['servers'][$i]['ssl_ca_path']

the certificate authorities you trust for server certificates. this is used to ensure that you are talking to a trusted server.


this configuration disables server certificate verification. use with caution.

when the database server is using a local connection or private network and ssl can not be configured you can use $cfg['mysqlsslwarningsafehosts'] to explicitly list the hostnames that are considered secure.

known issues

users with column-specific privileges are unable to “browse”

if a user has only column-specific privileges on some (but not all) columns in a table, “browse” will fail with an error message.

as a workaround, a bookmarked query with the same name as the table can be created, this will run when using the “browse” link instead. .

trouble logging back in after logging out using ‘http’ authentication

when using the ‘http’ auth_type, it can be impossible to log back in (when the logout comes manually or after a period of inactivity). .