{"id":45337,"date":"2026-11-25T22:08:26","date_gmt":"2026-11-25T22:08:26","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=45337"},"modified":"2026-11-25T22:08:26","modified_gmt":"2026-11-25T22:08:26","slug":"what-are-the-authentication-type-in-phpmyadmin-which-for-config-inc-php","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/what-are-the-authentication-type-in-phpmyadmin-which-for-config-inc-php\/","title":{"rendered":"What are the Authentication type in phpmyadmin which for config.inc.php"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">phpMyAdmin supports four authentication types, set per server with <code>$cfg[&#039;Servers&#039;][$i][&#039;auth_type&#039;]<\/code> in <code>config.inc.php<\/code>: <code>cookie<\/code> (the default), <code>config<\/code>, <code>http<\/code> and <code>signon<\/code>. 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 <code>blowfish_secret<\/code>, and the errors you are most likely to hit.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"992\" height=\"462\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/03\/image-781.png\" alt=\"List of phpMyAdmin authentication modes: Cookie, Config, HTTP, Signon and Swekey\" class=\"wp-image-45342\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/03\/image-781.png 992w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/03\/image-781-300x140.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/03\/image-781-768x358.png 768w\" sizes=\"auto, (max-width: 992px) 100vw, 992px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">In phpMyAdmin, the authentication type determines how users are authenticated when they try to access the phpMyAdmin interface. This setting is configured in the <code>config.inc.php<\/code> file of your phpMyAdmin installation, using the <code>$cfg['Servers'][$i]['auth_type']<\/code> directive. There are several authentication types available in phpMyAdmin:<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong><code>config<\/code><\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><code>config<\/code><\/strong>: This is the simplest method where the username and password are stored in the <code>config.inc.php<\/code> 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.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"957\" height=\"142\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/03\/image-777.png\" alt=\"PHP code in config.inc.php setting auth_type to config\" class=\"wp-image-45338\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/03\/image-777.png 957w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/03\/image-777-300x45.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/03\/image-777-768x114.png 768w\" sizes=\"auto, (max-width: 957px) 100vw, 957px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong><code>cookie<\/code><\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><code>cookie<\/code><\/strong>: 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 <code>config<\/code> and is commonly used for Internet-facing servers.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"972\" height=\"137\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/03\/image-778.png\" alt=\"PHP code in config.inc.php setting auth_type to cookie\" class=\"wp-image-45339\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/03\/image-778.png 972w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/03\/image-778-300x42.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/03\/image-778-768x108.png 768w\" sizes=\"auto, (max-width: 972px) 100vw, 972px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong><code>http<\/code><\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><code>http<\/code><\/strong>: 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&#8217;s authentication modules.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"967\" height=\"145\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/03\/image-779.png\" alt=\"PHP code in config.inc.php setting auth_type to http\" class=\"wp-image-45340\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/03\/image-779.png 967w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/03\/image-779-300x45.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/03\/image-779-768x115.png 768w\" sizes=\"auto, (max-width: 967px) 100vw, 967px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong><code>signon<\/code><\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><code>signon<\/code><\/strong>: 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.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"961\" height=\"140\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/03\/image-780.png\" alt=\"PHP code in config.inc.php setting auth_type to signon\" class=\"wp-image-45341\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/03\/image-780.png 961w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/03\/image-780-300x44.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/03\/image-780-768x112.png 768w\" sizes=\"auto, (max-width: 961px) 100vw, 961px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">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, <code>cookie<\/code> authentication provides a good balance between convenience and security.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Reference<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/howtolamp.com\/lamp\/phpmyadmin\/4.2\/authentication-modes\/\" rel=\"noopener\">https:\/\/howtolamp.com\/lamp\/phpmyadmin\/4.2\/authentication-modes\/<\/a><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Where config.inc.php lives and how auth_type is applied<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Each server block in <code>config.inc.php<\/code> has its own <code>auth_type<\/code>, so one phpMyAdmin installation can use different methods for different MySQL or MariaDB servers. If you do not set <code>auth_type<\/code>, phpMyAdmin uses <code>cookie<\/code>.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Installation method<\/th><th>Configuration file<\/th><\/tr><\/thead><tbody><tr><td>Release tarball or zip<\/td><td><code>config.inc.php<\/code> in the phpMyAdmin root. Create it by copying <code>config.sample.inc.php<\/code>.<\/td><\/tr><tr><td>Debian\/Ubuntu <code>phpmyadmin<\/code> package<\/td><td><code>\/etc\/phpmyadmin\/config.inc.php<\/code>, plus any files in <code>\/etc\/phpmyadmin\/conf.d\/<\/code><\/td><\/tr><tr><td>Official Docker image<\/td><td>Generated from environment variables. Add custom settings with a mounted <code>config.user.inc.php<\/code>.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">cd \/<span class=\"hljs-keyword\">var<\/span>\/www\/phpmyadmin\ncp config.sample.inc.php config.inc.php\nchown root:www-data config.inc.php\nchmod <span class=\"hljs-number\">640<\/span> config.inc.php<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> 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.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Comparing the four authentication types<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>auth_type<\/th><th>Who enters credentials<\/th><th>Credentials stored in config<\/th><th>Logout works<\/th><th>Typical use<\/th><\/tr><\/thead><tbody><tr><td><code>cookie<\/code><\/td><td>User, on the phpMyAdmin login form<\/td><td>No<\/td><td>Yes<\/td><td>Default choice. Multi-user and Internet-facing installs.<\/td><\/tr><tr><td><code>config<\/code><\/td><td>Nobody. They come from the file.<\/td><td>Yes<\/td><td>No<\/td><td>Local labs, or behind another login layer such as a VPN or SSO proxy<\/td><\/tr><tr><td><code>http<\/code><\/td><td>User, in the browser&#039;s Basic auth dialog<\/td><td>No<\/td><td>Unreliable, because browsers cache Basic credentials<\/td><td>Simple setups without cookies or sessions<\/td><\/tr><tr><td><code>signon<\/code><\/td><td>An external application<\/td><td>No (passed in a PHP session or a script)<\/td><td>Through <code>LogoutURL<\/code><\/td><td>Single sign-on from a control panel or portal<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">With <code>cookie<\/code>, <code>http<\/code> and <code>signon<\/code>, 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.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Configuring cookie authentication (recommended)<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Cookie mode encrypts the MySQL password in a cookie using <code>blowfish_secret<\/code>. 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.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\"># Prints 32 hex characters, which is 32 bytes as a string<\/span>\nopenssl rand -hex <span class=\"hljs-number\">16<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"php\"><span class=\"hljs-meta\">&lt;?php<\/span>\n<span class=\"hljs-keyword\">declare<\/span>(strict_types=<span class=\"hljs-number\">1<\/span>);\n\n<span class=\"hljs-comment\">\/\/ Paste the output of `openssl rand -hex 16` here<\/span>\n$cfg&#91;<span class=\"hljs-string\">'blowfish_secret'<\/span>] = <span class=\"hljs-string\">'replace_with_32_character_secret'<\/span>;\n\n$i = <span class=\"hljs-number\">0<\/span>;\n$i++;\n$cfg&#91;<span class=\"hljs-string\">'Servers'<\/span>]&#91;$i]&#91;<span class=\"hljs-string\">'auth_type'<\/span>] = <span class=\"hljs-string\">'cookie'<\/span>;\n$cfg&#91;<span class=\"hljs-string\">'Servers'<\/span>]&#91;$i]&#91;<span class=\"hljs-string\">'host'<\/span>] = <span class=\"hljs-string\">'localhost'<\/span>;\n$cfg&#91;<span class=\"hljs-string\">'Servers'<\/span>]&#91;$i]&#91;<span class=\"hljs-string\">'AllowNoPassword'<\/span>] = <span class=\"hljs-keyword\">false<\/span>; <span class=\"hljs-comment\">\/\/ reject empty passwords<\/span>\n$cfg&#91;<span class=\"hljs-string\">'Servers'<\/span>]&#91;$i]&#91;<span class=\"hljs-string\">'AllowRoot'<\/span>] = <span class=\"hljs-keyword\">false<\/span>;       <span class=\"hljs-comment\">\/\/ block the MySQL root account<\/span>\n\n<span class=\"hljs-comment\">\/\/ Idle time in seconds before re-login (default 1440)<\/span>\n$cfg&#91;<span class=\"hljs-string\">'LoginCookieValidity'<\/span>] = <span class=\"hljs-number\">1800<\/span>;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<ul class=\"wp-block-list\">\n<li><code>LoginCookieValidity<\/code> only works if PHP keeps sessions at least that long. Set <code>session.gc_maxlifetime<\/code> in <code>php.ini<\/code> to the same value or higher, or phpMyAdmin warns that your login may expire early.<\/li>\n\n\n<li><code>AllowRoot = false<\/code> stops people from guessing the root password through the login form. Create a named account for each administrator instead.<\/li>\n\n\n<li><code>$cfg[&#039;AllowArbitraryServer&#039;]<\/code> is off by default. Leave it off so the login form cannot be used to connect to other hosts.<\/li>\n\n\n<li><code>$cfg[&#039;CaptchaLoginPublicKey&#039;]<\/code> and <code>$cfg[&#039;CaptchaLoginPrivateKey&#039;]<\/code> add a reCAPTCHA to the login form, which slows down brute-force attempts.<\/li>\n<\/ul>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">CREATE USER <span class=\"hljs-string\">'pmaadmin'<\/span>@<span class=\"hljs-string\">'localhost'<\/span> IDENTIFIED BY <span class=\"hljs-string\">'Use-A-Long-Random-Password'<\/span>;\nGRANT ALL PRIVILEGES ON appdb.* TO <span class=\"hljs-string\">'pmaadmin'<\/span>@<span class=\"hljs-string\">'localhost'<\/span>;\nFLUSH PRIVILEGES;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Using config authentication safely<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In <code>config<\/code> 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.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">$cfg&#91;<span class=\"hljs-string\">'Servers'<\/span>]&#91;$i]&#91;<span class=\"hljs-string\">'auth_type'<\/span>] = <span class=\"hljs-string\">'config'<\/span>;\n$cfg&#91;<span class=\"hljs-string\">'Servers'<\/span>]&#91;$i]&#91;<span class=\"hljs-string\">'host'<\/span>] = <span class=\"hljs-string\">'127.0.0.1'<\/span>;\n$cfg&#91;<span class=\"hljs-string\">'Servers'<\/span>]&#91;$i]&#91;<span class=\"hljs-string\">'user'<\/span>] = <span class=\"hljs-string\">'pma_readonly'<\/span>;\n$cfg&#91;<span class=\"hljs-string\">'Servers'<\/span>]&#91;$i]&#91;<span class=\"hljs-string\">'password'<\/span>] = <span class=\"hljs-string\">'Use-A-Long-Random-Password'<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<ul class=\"wp-block-list\">\n<li>Use a least-privilege MySQL account, such as one with only <code>SELECT<\/code> on a single schema, never <code>root<\/code>.<\/li>\n\n\n<li>On Ubuntu, the MySQL <code>root<\/code> account often uses the <code>auth_socket<\/code> plugin. It cannot log in with a password through phpMyAdmin in any mode, so create a dedicated user.<\/li>\n\n\n<li>Put the web server&#039;s own authentication or an access proxy in front of it. <a href=\"https:\/\/www.devopsschool.com\/blog\/the-complete-pomerium-tutorial-from-absolute-beginner-to-advanced-zero-trust-access-engineering\/\">Pomerium<\/a> is one way to require SSO before the page loads.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Configuring http authentication<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In <code>http<\/code> mode, phpMyAdmin sends a <code>401<\/code> response with a <code>WWW-Authenticate: Basic<\/code> 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.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">$cfg&#91;<span class=\"hljs-string\">'Servers'<\/span>]&#91;$i]&#91;<span class=\"hljs-string\">'auth_type'<\/span>] = <span class=\"hljs-string\">'http'<\/span>;\n$cfg&#91;<span class=\"hljs-string\">'Servers'<\/span>]&#91;$i]&#91;<span class=\"hljs-string\">'host'<\/span>] = <span class=\"hljs-string\">'localhost'<\/span>;\n$cfg&#91;<span class=\"hljs-string\">'Servers'<\/span>]&#91;$i]&#91;<span class=\"hljs-string\">'auth_http_realm'<\/span>] = <span class=\"hljs-string\">'phpMyAdmin - production DB'<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">If the dialog keeps reappearing even with correct credentials, PHP is probably running under PHP-FPM or CGI and the <code>Authorization<\/code> header is not reaching PHP. On Apache 2.4.13 or later, pass the header through:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">Directory<\/span> \/<span class=\"hljs-attr\">var<\/span>\/<span class=\"hljs-attr\">www<\/span>\/<span class=\"hljs-attr\">phpmyadmin<\/span>&gt;<\/span>\n    CGIPassAuth On\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">Directory<\/span>&gt;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Configuring signon (single sign-on) authentication<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In <code>signon<\/code> 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 <code>SignonURL<\/code>.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">$cfg&#91;<span class=\"hljs-string\">'Servers'<\/span>]&#91;$i]&#91;<span class=\"hljs-string\">'auth_type'<\/span>] = <span class=\"hljs-string\">'signon'<\/span>;\n$cfg&#91;<span class=\"hljs-string\">'Servers'<\/span>]&#91;$i]&#91;<span class=\"hljs-string\">'host'<\/span>] = <span class=\"hljs-string\">'localhost'<\/span>;\n$cfg&#91;<span class=\"hljs-string\">'Servers'<\/span>]&#91;$i]&#91;<span class=\"hljs-string\">'SignonSession'<\/span>] = <span class=\"hljs-string\">'SignonSession'<\/span>; <span class=\"hljs-comment\">\/\/ must not be 'phpMyAdmin'<\/span>\n$cfg&#91;<span class=\"hljs-string\">'Servers'<\/span>]&#91;$i]&#91;<span class=\"hljs-string\">'SignonURL'<\/span>] = <span class=\"hljs-string\">'https:\/\/example.com\/portal\/signon.php'<\/span>;\n$cfg&#91;<span class=\"hljs-string\">'Servers'<\/span>]&#91;$i]&#91;<span class=\"hljs-string\">'LogoutURL'<\/span>] = <span class=\"hljs-string\">'https:\/\/example.com\/portal\/logout.php'<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"php\"><span class=\"hljs-meta\">&lt;?php<\/span>\n<span class=\"hljs-comment\">\/\/ signon.php: run this only after your application has authenticated the user<\/span>\nsession_name(<span class=\"hljs-string\">'SignonSession'<\/span>);\nsession_start();\n$_SESSION&#91;<span class=\"hljs-string\">'PMA_single_signon_user'<\/span>] = <span class=\"hljs-string\">'pmaadmin'<\/span>;\n$_SESSION&#91;<span class=\"hljs-string\">'PMA_single_signon_password'<\/span>] = <span class=\"hljs-string\">'Use-A-Long-Random-Password'<\/span>;\nsession_write_close();\nheader(<span class=\"hljs-string\">'Location: https:\/\/example.com\/phpmyadmin\/index.php'<\/span>);\n<span class=\"hljs-keyword\">exit<\/span>;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<ul class=\"wp-block-list\">\n<li>The session cookie must be visible to phpMyAdmin, so serve both apps on the same domain. If the paths differ, adjust <code>SignonCookieParams<\/code> or the session cookie path.<\/li>\n\n\n<li>Instead of a session, <code>SignonScript<\/code> can point to a PHP file that defines <code>get_login_credentials($user)<\/code> and returns <code>[user, password]<\/code>.<\/li>\n\n\n<li>phpMyAdmin ships a working example in <code>examples\/signon.php<\/code> in the release archive.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Corrections to the original<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The <code>config<\/code> section contains an empty numbered list item. It is a formatting leftover with no content and can be ignored.<\/li>\n\n\n<li>The <code>http<\/code> 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.<\/li>\n\n\n<li>The <code>cookie<\/code> description leaves out the required <code>blowfish_secret<\/code>. Cookie login does not work until a secret of the correct length is set.<\/li>\n\n\n<li>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.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Common errors and fixes<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Symptom<\/th><th>Cause<\/th><th>Fix<\/th><\/tr><\/thead><tbody><tr><td>Error asking for a secret passphrase, or a passphrase of the wrong length<\/td><td><code>blowfish_secret<\/code> is empty or not 32 bytes<\/td><td>Set a 32-character value generated with <code>openssl rand -hex 16<\/code><\/td><\/tr><tr><td>Login without a password is forbidden by configuration<\/td><td>Empty password and <code>AllowNoPassword<\/code> is false<\/td><td>Give the MySQL account a password. Do not enable <code>AllowNoPassword<\/code>.<\/td><\/tr><tr><td><code>#1045 Access denied for user<\/code><\/td><td>Wrong credentials, wrong host part such as <code>&#039;user&#039;@&#039;%&#039;<\/code> vs <code>&#039;user&#039;@&#039;localhost&#039;<\/code>, or <code>auth_socket<\/code> on root<\/td><td>Check <code>SELECT user, host, plugin FROM mysql.user;<\/code> and use a password-based account<\/td><\/tr><tr><td>Failed to set session cookie<\/td><td>Secure cookies over plain HTTP, or a broken PHP session save path<\/td><td>Serve over HTTPS and check that <code>session.save_path<\/code> exists and is writable<\/td><\/tr><tr><td>Logged out sooner than <code>LoginCookieValidity<\/code><\/td><td><code>session.gc_maxlifetime<\/code> is lower than the cookie validity<\/td><td>Raise <code>session.gc_maxlifetime<\/code> in <code>php.ini<\/code> and reload PHP-FPM<\/td><\/tr><tr><td>http mode prompts in a loop<\/td><td><code>Authorization<\/code> header not passed to PHP-FPM or CGI<\/td><td>Add <code>CGIPassAuth On<\/code> or the equivalent for your web server<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Hardening checklist<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Use <code>cookie<\/code> or <code>signon<\/code> for any installation reachable from a network, and keep <code>config<\/code> for isolated environments.<\/li>\n\n\n<li>Serve phpMyAdmin only over HTTPS and redirect HTTP to HTTPS at the web server.<\/li>\n\n\n<li>Restrict access by IP, VPN or an identity-aware proxy, and avoid the guessable <code>\/phpmyadmin<\/code> path.<\/li>\n\n\n<li>Set <code>AllowRoot = false<\/code> and give each administrator a named, least-privilege MySQL account.<\/li>\n\n\n<li>Keep phpMyAdmin updated and remove the <code>setup\/<\/code> directory after initial configuration.<\/li>\n\n\n<li>Send web server and MySQL authentication logs to your monitoring or SIEM so repeated failed logins are noticed.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Frequently asked questions<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">What is the default auth_type in phpMyAdmin?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><code>cookie<\/code>. If <code>$cfg[&#039;Servers&#039;][$i][&#039;auth_type&#039;]<\/code> is not set, phpMyAdmin shows its own login form and stores the encrypted credentials in a cookie.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Which phpMyAdmin authentication type is most secure?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><code>cookie<\/code> over HTTPS is the usual recommendation for standalone installs, and <code>signon<\/code> is a good choice when an existing SSO portal already authenticates users. <code>config<\/code> is the least secure, because anyone who reaches the URL is logged in automatically.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How do I log in to phpMyAdmin automatically without a password prompt?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Set <code>auth_type<\/code> to <code>config<\/code> and put <code>user<\/code> and <code>password<\/code> 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 <code>PMA_USER<\/code> and <code>PMA_PASSWORD<\/code> has the same effect.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Why can&#039;t I log in to phpMyAdmin as root on Ubuntu?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">MySQL on Ubuntu often sets up <code>root<\/code> with the <code>auth_socket<\/code> 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.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How long does a phpMyAdmin cookie login last?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">By default, 1440 seconds (24 minutes) of inactivity, controlled by <code>$cfg[&#039;LoginCookieValidity&#039;]<\/code>. PHP&#039;s <code>session.gc_maxlifetime<\/code> must be at least as long, or sessions expire sooner.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Related tutorials<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/category\/programming\/php\/\">More PHP tutorials<\/a><\/li>\n\n\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/category\/security\/\">More Security tutorials<\/a><\/li>\n\n\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/the-complete-pomerium-tutorial-from-absolute-beginner-to-advanced-zero-trust-access-engineering\/\">The Complete Pomerium Tutorial: From Absolute Beginner to Advanced Zero Trust Access Engineering<\/a><\/li>\n\n\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/cybersecurity-and-information-security-complete-tutorial-collection\/\">Cybersecurity and Information Security \u2013 Complete Tutorial Collection<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>phpMyAdmin supports four authentication types, set per server with $cfg[&#039;Servers&#039;][$i][&#039;auth_type&#039;] in config.inc.php: cookie (the default), config, http and signon. This page explains how each one works and&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[5150,24460],"tags":[5354],"class_list":["post-45337","post","type-post","status-publish","format-standard","hentry","category-php","category-security","tag-phpmyadmin"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/45337","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=45337"}],"version-history":[{"count":2,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/45337\/revisions"}],"predecessor-version":[{"id":80247,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/45337\/revisions\/80247"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=45337"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=45337"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=45337"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}