Changed password in phpMyAdmin on a Mac using XAMPP, now unable to access localhost/phpmyadmin

36,773

Solution 1

In your main installation folder for phpMyAdmin, you must have made a config.inc.php file, that is the file that you should be changing. Incase you don't have that file, then create it:

In the main installation folder(pMA) you would already have a file named: config.sample.inc.php, which contains the default configurations. Make a copy of this file and rename it to config.inc.php, you can do that directly using cp command (after navigating into the said folder):

cp ./config.sample.inc.php ./config.inc.php

Now make a few changes to this new file:

  1. Change the entry $cfg['Servers'][$i]['host'] = 'localhost'; to $cfg['Servers'][$i]['host'] = '127.0.0.1'; (as it does not work in some places)
  2. Write/change this line: $cfg['Servers'][$i]['AllowNoPassword'] = false;

Note: by the main installation folder for phpMyAdmin i mean the root folder of the installation of phpMyAdmin, i.e /<abc>/<xyz>/phpMyAdmin/.
Also make the 2nd change first, and make the 1st change only if the host is not found

Solution 2

Although, @bool dev have provided an answer above. I would like to share my version of how i resolved this using the terminal. I am using 10.12.5 (OS Serria)

Firstly, you need to have root access

sudo su

Then go to root folder

cd /

From there you need to navigate to the phpMyAdmin folder

cd Applications/XAMPP/xamppfiles/phpmyadmin/

Then using any editor open the config.inc.php file. (I used vi)

vi config.inc.php

Go to the following section in the file

/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = ''; // This is empty, set your password here

Then just restart your MySql server. And viola it should be working now.

Solution 3

Inside \xampp\phpmyadmin\config_inc.php

add or change like following code.
$cfg['Servers'][$i]['auth_type'] = 'cookie';

after that try to clear browsing data. then restart mysql.
It works for me. Hope it may help you.

Share:
36,773
Chris Sellers
Author by

Chris Sellers

Updated on June 19, 2020

Comments

  • Chris Sellers
    Chris Sellers almost 4 years

    I've read all the posts I could find about this, and none helped. I've deleted the XAMPP folder from my computer and reinstalled it from the DMG file, which of course fixed the problem, but I'd like to know how to fix it in the future.

    How it all started: I was logged in to phpMyAdmin on my Macbook (which runs Mac OS X v10.7.4). I saw the message advising me to change the password of root, which by default has no password. I went to the Manage Privileges tab and changed the password for root on localhosts, webdev and 127.0.0.1. In each case, I typed in the same short password and clicked "Generate Password," which created three different hashes.

    You know what comes next: When I tried to access localhost/phpmyadmin again, I was locked out with the message:

    Error
    
    MySQL said: 
    
    #1045 - Access denied for user 'root'@'localhost' (using password: NO) 
    
    phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection.  You should check the host, username and password in your configuration and make sure that  they correspond to the information given by the administrator of the MySQL server. 
    

    So I looked up stackoverflow, which advised me to set the password for root at the command line. I created a ".profile" file in my user directory, with "export PATH=/opt/local/bin:/opt/local/sbin:/Applications/xampp/xamppfiles/bin:$PATH" in it. That enabled me to start a mysql session, but (being a noob) I couldn't figure out what to do after that.

    Stackoverflow also advised that I could change the password in config.inc.php. I found this file at phpmyadmin/setup/frames/config.inc.php, but the line

    $cfg['Servers'][$i]['password'] = '';
    

    was not in there. I did find that line in phpmyadmin/libraries/config.default.php, but that file contains dire warnings against editing it. I found another likely file, phpmyadmin/setup/lib/common.inc.php, as well as phpmyadmin/scripts/signon.php, but in all cases, my computer prevented me from making any changes, saying I didn't have permissions. So that was frustrating.

    I'm sure this is a rookie mistake, or several of them, but I was curious to find that none of the things I looked up on stackoverflow helped me. I also wish the Mac OS made it easier to do things like create system files (e.g., .profile) and edit XAMPP files (e.g., common.inc.php). But what can you do.