8

I installed phpmyadmin in Win7, and if I type http://localhost/phpmyadmin/index.php in the browser, it will log in phpmyadmin as root user by default.

I created a new user but still there's no login window... every time it logs in as root by default.. how can I change user?

Many thanks!

5 Answers 5

7

How to set phpmyadmin prompt for login name and password

Set the auth_type to http in you config file of phpmyadmin

$cfg['Servers'][$i]['auth_type']     = 'http';      // Authentication method (config, http or cookie based)
$cfg['Servers'][$i]['user']          = 'root';      // MySQL user 
$cfg['Servers'][$i]['password']      = '';          // MySQL password (only needed 
                                                    // with 'config' auth_type)
3
  • Excellent and to the point answer
    – Sami
    Sep 10, 2012 at 13:26
  • I sing up to upvote. Dec 14, 2012 at 11:34
  • What if you're on cPanel on a hosted web account? I looked for this file and couldn't find it. I think the db server is shared among many databases.
    – toddmo
    Apr 25, 2018 at 17:34
3

this one was tricky to figure out at first, but in the end it's the Egg of Columbus:

  1. Close all open instances to PHPMyAdmin in your browser
  2. Clear cache and passwords (depending on your browser)
  3. Visit your PHPMyAdmin URL (localhost/phpmyadmin for example)

Enter your new username and password. Repeat process if you need to switch users again.

1
  • For example on XAMPP Mac it is XAMPP/xamppfiles/phpmyadmin/config.inc.php
    – Jono
    Jan 25, 2022 at 13:36
3

It sounds like you have the default settings, which, in most Windows packages I've seen, usually means that logging as 'root' with password '' is hard-wired into the code and ignores cookies etc. This means it will never offer a log-in window, because it thinks it already has your details, and until you change these settings, uberconversion's answer won't work as the appropriate cookie is never used.

After these settings are changed to use cookies (below), you can use uberconversion's method, or, in some versions of PHPMyAmdin, there is an icon in the bar of small icons in the top left of the screen that looks like an open door with a green arrow pointing to the left (mouseover text: "Log Out"), which does the same thing slightly more conveniently.

If you got PHPMyAdmin through XAMPP, there's a really easy way to change this at the end of this answer. If not, there are a couple of simple changes needed in config files. There's an answer on superuser.com that explains how to change this - I've included a tidied up answer based on that one here, to save time and in case something bizarre happens (e.g. if it was ever deleted or inaccessible for some crazy reason):

  1. Open the config.inc.php file. Since you are not seeing a log-in screen, you probably have $cfg['Servers'][$i]['auth_type'] = 'config' in there, probably around line 19. You will also see your name and password. Something like

    $cfg['Servers'][$i]['user'] = 'root';
    $cfg['Servers'][$i]['password'] = '';
    
  2. (Recommended) Change the blowfish_secret to any random string. As the file comments say, this string is used to encrypt your password in cookie based authentication (which is what you are about to change to).

    $cfg['blowfish_secret'] = 'a rAnd0m str11!11111!11!nG';
    
  3. Change the authentication type to cookie:

    $cfg['Servers'][$i]['auth_type'] = 'cookie'; // DEFAULT: 'config'
    
  4. (Recommended) Delete or comment out the lines that are storing your password. If, in Priviledges within PHPMyAdmin, the root user has no password, you probably should change that and if the config file says $cfg['Servers'][$i]['AllowNoPassword'] = true;, probably best to change true to false after giving root a password.

After doing this, it will start using cookies and will offer a log in window when the cookie doesn't log you straight in, so from here on, uberconversion's answer should work for you when you need to switch users. But uberconversion's answer won't work until PHPMyAdmin is set to use cookies. If it doesn't just work, you might need to restart mysql after changing root password.


If you got PHPMyAdmin as part of XAMPP (ignore this if you didn't), there's an even easier way. Go to localhost/security, follow the link below the table, and it gives you an option to input the password and change to cookie authentification. Note also that XAMPP is funny about passwords - it needs to be less than 16 characters.

0

Just open in a new window in Incognito (Chrome) or Private Browsing (Safari, Firefox) mode and visit the URL.

1
  • Handy tip (though still need to do what user568458 says, if it is a default XAMPP installation of phpadmin). May 7, 2015 at 13:36
-1

Make your AllowNoPassword line like this."false" may not work Try "falst"
$cfg['Servers'][$i]['AllowNoPassword'] = falst;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.