138

I have just installed XAMPP on my Windows XP machine, and I get an error saying:

Connection for controluser as defined in your configuration failed.

Before I installed XAMPP, I had a MySQL database installed and it had a password. I changed and put the password in config.inc.php for MySQL, and I got this error:

<?php
if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) {
    $uri = 'https://';
} else {
    $uri = 'http://';
}
$uri .= $_SERVER['HTTP_HOST'];
header('Location: '.$uri.'/xampp/');
exit;
?>

When I try to access index.php, it seems like something is wrong with the XAMPP installation. What can I do to fix this problem?

Makoto
  • 104,088
  • 27
  • 192
  • 230
  • 22
    IMHO this sort of questions are pretty much common and lots of time is wasted to fix them.Also by "defined scope of problems", its debatable if we can put such questn under "soft. tool commonly used by programmers" or "is a practical, answerable problem that is unique to soft development".So I request the SO veterans to consider such post carefully before marking "off topic". SO's become a trusted, one stop destination to get ans to programming problem,from persons who have faced and solved it. So it'd be helpful for programer to get exact answer here than searching elswhere for such problem. – Dexter Sep 24 '14 at 15:58
  • I found a solution from this. https://stackoverflow.com/a/54176422/4630590 – manojm Oct 20 '21 at 16:53

15 Answers15

252
  1. Open phpMyAdmin in a browser and log in as root.
  2. Create a database called phpmyadmin
  3. Create a user called pma and set the "host" to the hostname or IP address of your web server (if the web server and MySQL are on the same box use localhost), make a note of the password, and grant the new user full control over the phpmyadmin database. It is recommended that this user does not have access to anything other than this database.
  4. Go to the phpMyAdmin installation directory, where you should find a sub-directory called sql.
  5. In sql you will find a file called create_tables.sql. Open it in a text editor.
  6. In phpMyAdmin, select the phpmyadmin database and click on the "SQL" tab.
  7. Copy/paste the entire text from create_tables.sql into the text box, and run the query.
  8. Open the config.inc.php file in the phpMyAdmin install directory, and add the following lines (or change the existing settings if they are already there):

    $cfg['Servers'][1]['pmadb'] = 'phpmyadmin';
    $cfg['Servers'][1]['controluser'] = 'pma';
    $cfg['Servers'][1]['controlpass'] = '<your password>';
    
    // Note: The list below may grow as PMA evolves and more control tables are added
    // Use your common sense! Don't just blindly copypasta, look at what it means!
    $cfg['Servers'][1]['bookmarktable'] = 'pma_bookmark';
    $cfg['Servers'][1]['relation'] = 'pma_relation';
    $cfg['Servers'][1]['userconfig'] = 'pma_userconfig';
    $cfg['Servers'][1]['table_info'] = 'pma_table_info';
    $cfg['Servers'][1]['column_info'] = 'pma_column_info';
    $cfg['Servers'][1]['history'] = 'pma_history';
    $cfg['Servers'][1]['recent'] = 'pma_recent';
    $cfg['Servers'][1]['table_uiprefs'] = 'pma_table_uiprefs';
    $cfg['Servers'][1]['tracking'] = 'pma_tracking';
    $cfg['Servers'][1]['table_coords'] = 'pma_table_coords';
    $cfg['Servers'][1]['pdf_pages'] = 'pma_pdf_pages';
    $cfg['Servers'][1]['designer_coords'] = 'pma_designer_coords';
    
  9. Save and close the file.

IMPORTANT - PMA loads the config on login, evaluates it and stores it into the session data so the message will not disappear until you do this:

  1. Log out of phpMyAdmin and log in again

Problem solved.

Sang
  • 4,049
  • 3
  • 37
  • 47
DaveRandom
  • 87,921
  • 11
  • 154
  • 174
  • 3
    +1 for the "log out and log back in". I wasted five minutes not realising I had to do that. – Matthew G Jun 01 '13 at 11:44
  • 1
    @MatthewG Yes the config file is loaded into your session at the point where you log in to cut down on disk I/O, so that ^^ applies to any changes you might make to the PMA config file – DaveRandom Jun 01 '13 at 12:02
  • 14
    For some reason, my version of phpmyadmin is having the table names as "pma__bookmark" and so on with 2 "underscores". If anyone is having the same, then you should edit the "config.inc.php" accordingly. And BTW the config file is located in the "/etc/phpmyadmin" directory in Ubuntu – ajaybc Oct 24 '13 at 06:17
  • 1
    How it is possible for your instructions so effortlessly explain storage config whilst the PhpMyAdmin documentation so heinously obfuscates it is beyond me, but thanks for very much for this actually comprehensible explanation. – Jonline Jan 01 '14 at 22:42
  • 6
    On Ubuntu 14.04 the location for create_tables.sql is inside /usr/share/doc/phpmyadmin/examples/create_tables.sql.gz – karlingen Sep 16 '14 at 14:22
  • 2
    i didn't find config.inc.php – GvSharma Feb 03 '15 at 07:52
  • 5
    This is an excellent answer (the 100th `+` from me;)). However, I didn't find the *examples* directory where pointed in step 4. Instead it was here: `/usr/share/doc/phpmyadmin/examples` and there I found the compressed sql file: `create_tables.sql.gz`. – Majid Fouladpour Feb 04 '15 at 13:08
  • I had followed above steps, but the problem was not solved. After some days I repeated these steps. then I noticed a message at the bottom saying that I need to `FLUSH PRIVILEGES;` to make it work. From the first time I only missed to flush the privileges. Now, I can also login with `pma`, earlier could not. – Gautam Arya Sep 21 '15 at 07:12
  • 1
    On windows 10 for the step "In examples you will find a file called create_tables.sql. Open it in a text editor." I found it located in phpMyAdmin/sql. – shayster01 Jan 23 '16 at 17:10
  • the double underscore in table names creates an issue. I just edited all __ with _ and solved the issue. Kudos for tips to the issue by fellows. – Bineesh Sep 29 '16 at 07:26
  • Just reconfigure if you don't have any important data, or backup database and reconfigure. – ARKhan Aug 10 '17 at 14:45
  • phpMyAdmin doesn't have a login or logout. I'm guessing you mean to close its tab or window, clear the cache, and run it again. – David Spector Oct 18 '17 at 01:21
  • 1
    @David Spector the logout button for phpMyAdmin looks like a door with an arrow pointing left and is located just below the logo in the top area of the left pane. It looks like this: https://i.imgur.com/Iwvo3Lu.png – Eric Lindsey Aug 21 '18 at 21:10
  • In the config.inc.php you might find the value keys to be '$cfg['Servers'][$i]['pmadb']' instead of '$cfg['Servers'][1]['pmadb']'. In this case keep the $i in the key and just change the value as described in the solution. – elMeroMero Oct 28 '18 at 14:09
  • this doesn't work because they moved it to /etc/phpmyadmin/config-db.php – thang Mar 16 '19 at 18:32
  • No other software out there is more convoluted, complicated, and senseless to setup. Notwithstanding this critique, phpMyAdmin is great. – gone Mar 08 '20 at 14:06
  • Very useful answer, In 8 I added my password of pma user – Renjitha22 Mar 30 '21 at 15:19
137

If you got here and you are using Debian/Ubuntu (or any other dpkg based distro), execute the following command:

sudo dpkg-reconfigure phpmyadmin

The phpmyadmin package contains the script to perform this operation for you, all it needs is a user with permissions. sudo is not required if you're logged in as root, of course.

EDIT: It might be worth trying to drop the current phpmyadmin user.

Or Cohen
  • 1,536
  • 1
  • 9
  • 7
  • 2
    This worked for me, I just had to reinstall the database it asked. Thanks. (Ubuntu 12.04) – ino Aug 15 '13 at 23:17
  • 18
    I had to type "pma" instead of "phpmyadmin" for the control user during the configuration to make this work. – Hardell Dec 01 '13 at 01:20
  • Working fine on Debian Jessie 3.14.9-1 (2014-06-30). Had to use "pma" instead of "phpmyadmin" much like @Hardell specified. Thanks! – eluong Jul 10 '14 at 15:37
  • 2
    Dropping 'phpmyadmin' user _first_ and running 'sudo dpkg-reconfigure phpmyadmin' after worked for me. Thanks! – B. Shea Nov 12 '14 at 15:17
  • I installed phpmyadmin through installing xampp, would this work for me as well? – Naguib Ihab Jan 29 '15 at 06:14
  • This worked for me. set user to "pma" instead of "phpmyadmin" – David Okwii Aug 01 '15 at 13:51
  • 1
    **note:** this will erase all configured servers, if any. – Raptor Aug 12 '15 at 02:19
  • @Hardell I had already reinstalled phpmyadmin once, but following the advice to call the control user 'pma' did the trick – Auspex Jan 11 '16 at 14:39
  • you should mention that this will work only if you have installed phpMyAdmin by means of repositories – machineaddict Jan 28 '16 at 09:43
  • there is config file /etc/config-db.php, it stores pma user name and password – Weijing Jay Lin Mar 09 '16 at 06:15
  • 1
    @DotKu, or is the config file at /etc/phpmyadmin/config-db.php that stores the name and password. And in that file I had to update to: $dbuser='pma'; and $dbpass=''; After a logout/login that finally got rid of the "Connection for controluser as defined in your configuration failed." error message. ... Oh, yes and before that I had to paste in the sql to create the tables. (This was another struggle, as there are multiple versions out there). ............. too bad this Q is closed or I'd enter another, more complete answer. – Elliptical view Oct 04 '16 at 15:59
  • Clean solution, I tried @DaveRandom's solution before this, but it didn't work properly. With this command my pma has been fixed. Thx. – Zsolt Takács Feb 22 '17 at 10:03
  • Worked for me. I actually exited the program as I was afraid that my current databases were going to be erased. And then it actually executed the replacement script and that did the trick. Thanks. – Ansjovis86 Apr 09 '17 at 18:43
  • In case it is still not working after running `dpkg-reconfigure phpmyadmin`, restarting `php-fpm` service would help. – Jared Chu Aug 22 '23 at 01:53
25

Just comment out the whole "User for advanced features" and "Advanced phpMyAdmin features" code blocks in config.inc.php.

tchap
  • 3,412
  • 3
  • 29
  • 46
streak
  • 1,121
  • 1
  • 19
  • 28
16

Have you recently changed your MySQL Server root password? If answer is YES, than this is the cause of the error / warning inside phpMyAdmin console. To fix the problem, simply edit your phpMyAdmin’s config-db.php file and setup the proper database password.

First answer is messing too much in my view and second answer did not work for me. So:

In Linux-based servers the file is usually located in:

/etc/phpmyadmin/config-db.php

or:

/etc/phpMyAdmin/config-db.php

Example: (My File looked like this and I changed the user fromphpmyadmin to admin, the username I created for maintaining my database through phpmyadmin, and put in the appropriate password.

$dbuser='phpmyadmin';
$dbpass=''; // set current password between quotes ' '
$basepath='';
$dbname='phpmyadmin';
$dbserver='';
$dbport='';
$dbtype='mysql';

credits: http://tehnoblog.org/phpmyadmin-error-connection-for-controluser-as-defined-in-your-configuration-failed/

bomben
  • 590
  • 6
  • 16
5

This worked for me with phpmyadmin under Ubuntu 16.04:

I edited /etc/phpmyadmin/config.inc.php and changed the following 2 lines:

$cfg['Servers'][$i]['controluser'] = 'root'; 
$cfg['Servers'][$i]['controlpass'] = 'thepasswordgiventoroot'; 
Dominique H.
  • 59
  • 1
  • 1
4

This worked for me with phpmyadmin under Ubuntu 16.04:

I edited /etc/phpmyadmin/config.inc.php and changed the following 2 lines:

$cfg['Servers'][$i]['controluser'] = 'pma'; 
$cfg['Servers'][$i]['controlpass'] = 'pass pma'; 
Simas Joneliunas
  • 2,890
  • 20
  • 28
  • 35
3

On Ubunbtu.

Ben's message is close but it's not the root password that is the problem, the problem I found was I had created a password for the phpmyadmin database when I installed it. This password is not carried into the installation on ubuntu so the variable $dbpass=''; in the database settings file is empty and not the password you set.

  1. To check you have the right password at the command line login to mysql using the following command: mysql -u phpmyadmin -p try a blank password I found I got access denied, enter the command again using the password you set during installation. If it logs in you now know what the password is.
  2. Edit /etc/phpadmin/config-db.php and change $dbpass=''; to $dbpass='Your Password'; and save the file.
  3. Edit /etc/dbconfig-common/phpmyadmin.conf change dbc_dbpass=''; to dbc_dbpass='Your Password'; and save the file. Close your browser and reload you will now find the message has gone way.
Clive Wi
  • 31
  • 1
2

"For me to make it work again I just deleted the files

ib_logfile0 and

ib_logfile1 .

from :

/Applications/MAMP/db/mysql56/ib_logfile0 "

On XAMPP its Xampp/xamppfiles/var/mysql

Got this from PHP Warning: mysqli_connect(): (HY000/2002): Connection refused

Helper -Joe
  • 101
  • 6
2

on ubuntu /etc/phpmyadmin/config-db.php

make sure the password matches your config.inc.php for the control user

also for the blowfish too short error

edit /var/lib/phpmyadmin/blowfish_secret.inc.php and make the key longer

Samsul Islam
  • 2,581
  • 2
  • 17
  • 23
Royce
  • 21
  • 1
0

The problem is that PhpMyAdmin control user (usually: pma) password does not match the mysql user: pma (same user) password.

To fix it, 1. Set the password you want for user pma here:

"C:\xampp\phpMyAdmin\config.inc.php"

$cfg['Servers'][$i]['controlpass'] = 'your_new_phpmyadmin_pass';

(should be like on line 32)

Then go to mysql, login as root, go to: (I used phpmyadmin to go here)

Database: mysql »Table: user

Edit the user: pma

Select "Password" from the function list (left column) and set "your_new_phpmyadmin_pass" on the right column and hit go.

Restart mysql server.

Now the message should disappear.

Tarik
  • 4,270
  • 38
  • 35
0

I just simply make changes on config.inc.php file. There is password in error in this link $cfg['Servers'][$i]['password'] = 'your password '; and now its perfectly worked .

  • please edit your question and add more details. This is of low quality. – Mathews Sunny Dec 09 '17 at 09:03
  • The above is the resolution , i haven't followed above steps. I just simply go to config.inc.php directory and open this file config.inc.php in notepad and the changed this line $cfg['Servers'][$i]['password'] = 'your password ' – Mohit Sharma Dec 09 '17 at 09:29
  • I saw the password is mentioned there is wrong and I put correct password again and saved it and run the phpmyadmin again and it running properly now – Mohit Sharma Dec 09 '17 at 09:31
0

on ubuntu 18.04 in etc/phpmyadmin/config.inc.php comment all the block

Optional: User for advanced features

Rahul Agarwal
  • 4,034
  • 7
  • 27
  • 51
boaz
  • 1
0

on ubuntu, these steps worked for me...

1. sudo gedit /etc/phpmyadmin/config.inc.php.

2. uncomment[remove(/)]  following lines :-

    $cfg['Servers'][$i]['AllowNoPassword'] = TRUE;

3. comment[add(/)] following lines :-     

   //$cfg['Servers'][$i]['controluser'] = $dbuser;
   //$cfg['Servers'][$i]['controlpass'] = $dbpass;
Aahad
  • 507
  • 4
  • 13
0

So I deleted the phpmyadmin user accidently but not the table and the only and best answer that worked these days have been this one: https://stackoverflow.com/a/40632599/15821993

open the directory /etc/phpmyadmin/ in the terminal and use

sudo nano config-db.php

to open it as a root (other users have no access)

there you can find the username and password of the deleted user. If you want to change them you can do it to whatever you want and safe the file or you reuse them in the next step.

After you got this infos or changed the credentials: login to phpmyadmin console and create a new user for the db phpmyadmin with same username and password as in the file. Grant all rights to the user for this db only and you are done.

logout and login again at phpMyAdmin and all errors are gone.

sefre
  • 63
  • 5
-1

Having just installed the XAMPP today, I decided to use a different default port for mysql, which was horrible. Make sure to add these lines to the phpMyAdmin config.inc.php:

$cfg['Servers'][$i]['host'] = 'localhost';

$cfg['Servers'][$i]['port'] = 'port';`
Igoris Azanovas
  • 1,640
  • 1
  • 22
  • 37
David
  • 1