MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

What are the Authentication type in phpmyadmin which for config.inc.php

phpMyAdmin supports four authentication types, set per server with $cfg['Servers'][$i]['auth_type'] in config.inc.php: cookie (the default), config, http and signon. This page explains how each one works and gives a working configuration for each. It also covers the extra settings each type depends on, such as blowfish_secret, and the errors you are most likely to hit.

List of phpMyAdmin authentication modes: Cookie, Config, HTTP, Signon and Swekey

In phpMyAdmin, the authentication type determines how users are authenticated when they try to access the phpMyAdmin interface. This setting is configured in the config.inc.php file of your phpMyAdmin installation, using the $cfg['Servers'][$i]['auth_type'] directive. There are several authentication types available in phpMyAdmin:

config

config: This is the simplest method where the username and password are stored in the config.inc.php file. This method is not recommended for servers accessible from the Internet due to security concerns, as it does not prompt the user for a username or password.

PHP code in config.inc.php setting auth_type to config

cookie

cookie: This method uses cookies for authentication. The user will be presented with a login screen to enter their username and password. This method is more secure than config and is commonly used for Internet-facing servers.

PHP code in config.inc.php setting auth_type to cookie

http

http: With this method, HTTP Authentication is used. The web server manages the login process, and the login dialogue is presented by the browser itself. This method also allows for the use of web server’s authentication modules.

PHP code in config.inc.php setting auth_type to http

signon

signon: This advanced authentication method allows for single sign-on capabilities. It uses a session-based mechanism and requires additional scripting to integrate phpMyAdmin logins with other application logins.

PHP code in config.inc.php setting auth_type to signon

Choosing the right authentication type depends on your specific needs, including the level of security required and whether the phpMyAdmin installation is exposed to the Internet. For most users, cookie authentication provides a good balance between convenience and security.

Reference


Where config.inc.php lives and how auth_type is applied

Each server block in config.inc.php has its own auth_type, so one phpMyAdmin installation can use different methods for different MySQL or MariaDB servers. If you do not set auth_type, phpMyAdmin uses cookie.

Installation methodConfiguration file
Release tarball or zipconfig.inc.php in the phpMyAdmin root. Create it by copying config.sample.inc.php.
Debian/Ubuntu phpmyadmin package/etc/phpmyadmin/config.inc.php, plus any files in /etc/phpmyadmin/conf.d/
Official Docker imageGenerated from environment variables. Add custom settings with a mounted config.user.inc.php.
cd /var/www/phpmyadmin
cp config.sample.inc.php config.inc.php
chown root:www-data config.inc.php
chmod 640 config.inc.phpCode language: JavaScript (javascript)

Note: phpMyAdmin refuses to load a world-writable configuration file and shows a wrong-permissions error. Make the file readable by the web server user and writable only by root or the deploying user.

Comparing the four authentication types

auth_typeWho enters credentialsCredentials stored in configLogout worksTypical use
cookieUser, on the phpMyAdmin login formNoYesDefault choice. Multi-user and Internet-facing installs.
configNobody. They come from the file.YesNoLocal labs, or behind another login layer such as a VPN or SSO proxy
httpUser, in the browser's Basic auth dialogNoUnreliable, because browsers cache Basic credentialsSimple setups without cookies or sessions
signonAn external applicationNo (passed in a PHP session or a script)Through LogoutURLSingle sign-on from a control panel or portal

With cookie, http and signon, the credentials are MySQL credentials. phpMyAdmin has no separate user database of its own. What a person can do after logging in is decided entirely by the MySQL grants for that account.

Configuring cookie authentication (recommended)

Cookie mode encrypts the MySQL password in a cookie using blowfish_secret. The steps above do not mention this setting, but without it phpMyAdmin shows the error *The configuration file now needs a secret passphrase (blowfish_secret)*. Current 5.2 releases expect the secret to be exactly 32 bytes long.

# Prints 32 hex characters, which is 32 bytes as a string
openssl rand -hex 16Code language: PHP (php)
<?php
declare(strict_types=1);

// Paste the output of `openssl rand -hex 16` here
$cfg['blowfish_secret'] = 'replace_with_32_character_secret';

$i = 0;
$i++;
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['AllowNoPassword'] = false; // reject empty passwords
$cfg['Servers'][$i]['AllowRoot'] = false;       // block the MySQL root account

// Idle time in seconds before re-login (default 1440)
$cfg['LoginCookieValidity'] = 1800;Code language: HTML, XML (xml)
  • LoginCookieValidity only works if PHP keeps sessions at least that long. Set session.gc_maxlifetime in php.ini to the same value or higher, or phpMyAdmin warns that your login may expire early.
  • AllowRoot = false stops people from guessing the root password through the login form. Create a named account for each administrator instead.
  • $cfg['AllowArbitraryServer'] is off by default. Leave it off so the login form cannot be used to connect to other hosts.
  • $cfg['CaptchaLoginPublicKey'] and $cfg['CaptchaLoginPrivateKey'] add a reCAPTCHA to the login form, which slows down brute-force attempts.
CREATE USER 'pmaadmin'@'localhost' IDENTIFIED BY 'Use-A-Long-Random-Password';
GRANT ALL PRIVILEGES ON appdb.* TO 'pmaadmin'@'localhost';
FLUSH PRIVILEGES;Code language: JavaScript (javascript)

Using config authentication safely

In config mode, anyone who can reach the phpMyAdmin URL is logged in as the account in the file, with no prompt. Only use it when access is already restricted somewhere else, for example on localhost only, behind a VPN, or behind an identity-aware proxy.

$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['host'] = '127.0.0.1';
$cfg['Servers'][$i]['user'] = 'pma_readonly';
$cfg['Servers'][$i]['password'] = 'Use-A-Long-Random-Password';Code language: PHP (php)
  • Use a least-privilege MySQL account, such as one with only SELECT on a single schema, never root.
  • On Ubuntu, the MySQL root account often uses the auth_socket plugin. It cannot log in with a password through phpMyAdmin in any mode, so create a dedicated user.
  • Put the web server's own authentication or an access proxy in front of it. Pomerium is one way to require SSO before the page loads.

Configuring http authentication

In http mode, phpMyAdmin sends a 401 response with a WWW-Authenticate: Basic header. The browser shows its own dialog, and the username and password are used to connect to MySQL. Basic auth only base64-encodes the credentials and sends them with every request, so serve phpMyAdmin over HTTPS only.

$cfg['Servers'][$i]['auth_type'] = 'http';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['auth_http_realm'] = 'phpMyAdmin - production DB';Code language: PHP (php)

If the dialog keeps reappearing even with correct credentials, PHP is probably running under PHP-FPM or CGI and the Authorization header is not reaching PHP. On Apache 2.4.13 or later, pass the header through:

<Directory /var/www/phpmyadmin>
    CGIPassAuth On
</Directory>Code language: HTML, XML (xml)

Configuring signon (single sign-on) authentication

In signon mode, phpMyAdmin reads the credentials from a named PHP session that your own application fills in after it has authenticated the user. Users who arrive without valid session data are redirected to SignonURL.

$cfg['Servers'][$i]['auth_type'] = 'signon';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['SignonSession'] = 'SignonSession'; // must not be 'phpMyAdmin'
$cfg['Servers'][$i]['SignonURL'] = 'https://example.com/portal/signon.php';
$cfg['Servers'][$i]['LogoutURL'] = 'https://example.com/portal/logout.php';Code language: PHP (php)
<?php
// signon.php: run this only after your application has authenticated the user
session_name('SignonSession');
session_start();
$_SESSION['PMA_single_signon_user'] = 'pmaadmin';
$_SESSION['PMA_single_signon_password'] = 'Use-A-Long-Random-Password';
session_write_close();
header('Location: https://example.com/phpmyadmin/index.php');
exit;Code language: HTML, XML (xml)
  • The session cookie must be visible to phpMyAdmin, so serve both apps on the same domain. If the paths differ, adjust SignonCookieParams or the session cookie path.
  • Instead of a session, SignonScript can point to a PHP file that defines get_login_credentials($user) and returns [user, password].
  • phpMyAdmin ships a working example in examples/signon.php in the release archive.

Corrections to the original

  • The config section contains an empty numbered list item. It is a formatting leftover with no content and can be ignored.
  • The http description says the web server manages the login. In fact, phpMyAdmin sends the Basic auth challenge itself, and whatever credentials the browser returns are used as MySQL credentials. If the web server also runs its own Basic auth, its usernames must match MySQL accounts.
  • The cookie description leaves out the required blowfish_secret. Cookie login does not work until a secret of the correct length is set.
  • The reference link covers phpMyAdmin 4.2, which is long out of support. The authentication chapter of the official phpMyAdmin documentation for your installed version is the current source.

Common errors and fixes

SymptomCauseFix
Error asking for a secret passphrase, or a passphrase of the wrong lengthblowfish_secret is empty or not 32 bytesSet a 32-character value generated with openssl rand -hex 16
Login without a password is forbidden by configurationEmpty password and AllowNoPassword is falseGive the MySQL account a password. Do not enable AllowNoPassword.
#1045 Access denied for userWrong credentials, wrong host part such as 'user'@'%' vs 'user'@'localhost', or auth_socket on rootCheck SELECT user, host, plugin FROM mysql.user; and use a password-based account
Failed to set session cookieSecure cookies over plain HTTP, or a broken PHP session save pathServe over HTTPS and check that session.save_path exists and is writable
Logged out sooner than LoginCookieValiditysession.gc_maxlifetime is lower than the cookie validityRaise session.gc_maxlifetime in php.ini and reload PHP-FPM
http mode prompts in a loopAuthorization header not passed to PHP-FPM or CGIAdd CGIPassAuth On or the equivalent for your web server

Hardening checklist

  1. Use cookie or signon for any installation reachable from a network, and keep config for isolated environments.
  2. Serve phpMyAdmin only over HTTPS and redirect HTTP to HTTPS at the web server.
  3. Restrict access by IP, VPN or an identity-aware proxy, and avoid the guessable /phpmyadmin path.
  4. Set AllowRoot = false and give each administrator a named, least-privilege MySQL account.
  5. Keep phpMyAdmin updated and remove the setup/ directory after initial configuration.
  6. Send web server and MySQL authentication logs to your monitoring or SIEM so repeated failed logins are noticed.

Frequently asked questions

What is the default auth_type in phpMyAdmin?

cookie. If $cfg['Servers'][$i]['auth_type'] is not set, phpMyAdmin shows its own login form and stores the encrypted credentials in a cookie.

Which phpMyAdmin authentication type is most secure?

cookie over HTTPS is the usual recommendation for standalone installs, and signon is a good choice when an existing SSO portal already authenticates users. config is the least secure, because anyone who reaches the URL is logged in automatically.

How do I log in to phpMyAdmin automatically without a password prompt?

Set auth_type to config and put user and password in the server block. Only do this when access is already restricted by localhost binding, a VPN or an authenticating proxy. In the official Docker image, setting PMA_USER and PMA_PASSWORD has the same effect.

Why can't I log in to phpMyAdmin as root on Ubuntu?

MySQL on Ubuntu often sets up root with the auth_socket plugin, which accepts only local socket connections from the OS root user, not password logins. Create a separate MySQL user with a password and the grants you need.

How long does a phpMyAdmin cookie login last?

By default, 1440 seconds (24 minutes) of inactivity, controlled by $cfg['LoginCookieValidity']. PHP's session.gc_maxlifetime must be at least as long, or sessions expire sooner.

Related tutorials

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services โ€” all in one place.

Explore Hospitals
I'm Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms. I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.

Related Posts

Xampp Troubleshooting Guide

Log Levels of Apache, MySql, PHPMyAdmin, PHP, Composer Apache MySQL PHPMyAdmin PHPMyAdmin’s log level is primarily controlled by the PHP configuration, as it’s a PHP application. PHP…

Read More

phpmyadmin Tutorials: Authentication Methods

PhpMyAdmin supports various authentication methods, some of which are: Recommended for Multiuser HTTPย and cookie authentication modes are recommended in aย multi-user environmentย where you want to give users access…

Read More

How to install WordPress on Windows using XAMPP? Part-1

How to install WordPress on localhost XAMPP? What is the WordPress? WordPress is a free and open-source (Content Management System) which is based on PHP and MySql….

Read More

HOW TO CREATE EVENT CALENDAR IN LARAVEL? PART-3

Step 1.Create a Database in phpMyAdmin. (Write the same name of database which was written in .enf databse name). Step 2.  We use the migrate command to…

Read More

How to upload laravel project on cPanel.

Open cpanel what you have url/cpanel Step: 2 Step:3 go to www folder Step:4 then click upload button. Step:5 select your file where you have to file…

Read More

How to fix an error of PhpMyAdmin access denied in xamp mySql.

Error resolving of PhpMyAdmin access denied. For most first time install, accessing http://localhost/PhpMyAdmin will directly take us to the PhpMyAdmin web interface without asking for password or…

Read More
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
0
Would love your thoughts, please comment.x
()
x