16

We have installed PHPMyAdmin on a windows machine running IIS 7.0.
We are able to connect to MySQL using command-line, But we are not able to connect using PHPMyAdmin.
The error displayed is: Error #1045 Cannot log in to the MySQL server.
Can somebody please help?

PHP Version 5.4.0
mysqlnd 5.0.10 - 20111026 - $Revision: 323634 $
phpMyAdmin-3.5.4-rc1-all-languages.7z

EDIT :
I followed the link below with no success, mean i changed that password but phpmyadmin still has that error...
C.5.4.1.1. Resetting the Root Password: Windows Systems

Also there is thread like below in stack with no help :
Random error: #1045 Cannot log in to the MySQL server
but that error is not random -> i always have that error...

And this is config.inc.php file in phpmyadmin folder:

<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
 * Config file view and save screen
 *
 * @package PhpMyAdmin-setup
 */

if (!defined('PHPMYADMIN')) {
    exit;
}

/**
 * Core libraries.
 */
require_once './libraries/config/FormDisplay.class.php';
require_once './setup/lib/index.lib.php';
require_once './setup/lib/ConfigGenerator.class.php';

$config_readable = false;
$config_writable = false;
$config_exists = false;
check_config_rw($config_readable, $config_writable, $config_exists);
?>
<h2><?php echo __('Configuration file') ?></h2>
<?php display_form_top('config.php'); ?>
<input type="hidden" name="eol" value="<?php echo htmlspecialchars(PMA_ifSetOr($_GET['eol'], 'unix')) ?>" />
<?php display_fieldset_top('', '', null, array('class' => 'simple')); ?>
<tr>
    <td>
        <textarea cols="50" rows="20" name="textconfig" id="textconfig" spellcheck="false"><?php
            echo htmlspecialchars(ConfigGenerator::getConfigFile())
        ?></textarea>
    </td>
</tr>
<tr>
    <td class="lastrow" style="text-align: left">
        <input type="submit" name="submit_download" value="<?php echo __('Download') ?>" class="green" />
        <input type="submit" name="submit_save" value="<?php echo __('Save') ?>"<?php if (!$config_writable) echo ' disabled="disabled"' ?> />
    </td>
</tr>
<?php
display_fieldset_bottom_simple();
display_form_bottom();
?>

where part of these codes should i change?

Thanks.

Community
  • 1
  • 1
SilverLight
  • 19,668
  • 65
  • 192
  • 300

11 Answers11

22

In Linux I resolve this problem by going to the root command prompt type:

# mysqladmin -u root password 'Secret Phrase Here'

Then go back and login. Works every time!

  • 1
    The only thing that fixed problem with priviliges over vagrant! 4 hours of searching, adding comment in case someone will stumble uppon simmilar problem with phpmyadmin installation in vagrant virtualbox. + it will work in provisional.sh – versedi Apr 05 '15 at 23:56
16

You need to do two additional things after following the link that you have mentioned in your post:

One have to map the changed login cridentials in phpmyadmin's config.inc.php

and second, you need to restart your web and mysql servers..

php version is not the issue here..you need to go to phpmyadmin installation directory and find file config.inc.php and in that file put your current mysql password at line

$cfg['Servers'][$i]['user'] = 'root'; //mysql username here
$cfg['Servers'][$i]['password'] = 'password'; //mysql password here
000
  • 3,976
  • 4
  • 25
  • 39
  • thanks for the answer -> would you please explain more. also i think that phpmyadmin does not support php 5.4.0! am i right? should i change php version or not? – SilverLight Nov 13 '12 at 09:11
  • i guess you have pasted code of _phpmyadmin's index.php_..i have updated my answer..pls check.. – 000 Nov 13 '12 at 09:24
  • thanks for the edit -> but i do n't have these lines in that file -> please see my edit again. – SilverLight Nov 13 '12 at 09:24
  • no, it's config.inc.php file -> i 've downloaded from here -> http://sourceforge.net/projects/phpmyadmin/files/phpMyAdmin/3.5.4-rc1/phpMyAdmin-3.5.4-rc1-all-languages.7z/download#!md5!0c6325b38f77e5137fdcec810e01a8d8 – SilverLight Nov 13 '12 at 09:48
  • 1
    there's a catch..thanks for giving me the download link to make things clear..you have pasted code from _/setup/config.php_ but i am talking about _/config.inc.php_ which in this setup doesn't exist..so you need to rename _/config.sample.inc.php_ to _config.inc.php_ and paste the above code in it after `$cfg['Servers'][$i]['host'] = 'localhost';` line.. – 000 Nov 13 '12 at 09:53
  • is it giving the same error..??have you restarted your web server..?? – 000 Nov 13 '12 at 10:24
  • mmmmmmm i restarted my iis, please wait... now i restarted my web server -> still does not work -> what is this damn error? – SilverLight Nov 13 '12 at 10:39
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/19474/discussion-between-rishi-kalia-and-moonlight) – 000 Nov 13 '12 at 10:43
5

If you are installing first time then please try login with username and password as root

Akeel
  • 51
  • 1
  • 3
5

another thing that worked for me after everything didn't - change "localhost" in config.inc.php to 127.0.0.1

ItamarBe
  • 482
  • 1
  • 5
  • 12
4

In mysql 5.7 the auth mechanism changed, documentation can be found in the official manual here.

Using the system root user (or sudo) you can connect to the mysql database with the mysql 'root' user via CLI. All other users will work, too.

In phpmyadmin however, all mysql users will work, but not the mysql 'root' user.

This comes from here:

$ mysql -Ne "select Host,User,plugin from mysql.user where user='root';"
+-----------+------+-----------------------+
| localhost | root | auth_socket |
|  hostname | root | mysql_native_password |
+-----------+------+-----------------------+

To 'fix' this security feature, do:

mysql -Ne "update mysql.user set plugin='mysql_native_password' where User='root' and Host='localhost'; flush privileges;"

More on this can also be found here in the manual.

sjas
  • 18,644
  • 14
  • 87
  • 92
2

For ubuntu users, your config.inc.php file should be like this

/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['user'] = 'username';
$cfg['Servers'][$i]['password'] = 'password';
/* Server parameters */
$cfg['Servers'][$i]['host'] = '127.0.0.1';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['AllowNoPassword'] = false;
/**
 * phpMyAdmin configuration storage settings.
 */
/* User used to manipulate with storage */
// $cfg['Servers'][$i]['controlhost'] = '';
// $cfg['Servers'][$i]['controlport'] = '';
// $cfg['Servers'][$i]['controluser'] = 'pma';
// $cfg['Servers'][$i]['controlpass'] = '';
MeVimalkumar
  • 3,192
  • 2
  • 15
  • 26
1

When you change your passwords in the security tab, there are two sections, one above and one below. I think the common mistake here is that others try to log-in with the account they have set "below" the one used for htaccess, whereas they should log in to the password they set on the above section. That's how I fixed mine.

carl dallo
  • 11
  • 1
1

a number of answers; check out this one also; make sure that no instance of mysql is running, always brought by not ending your sessions well. get the super user rights with

sudo su

and type your password when prompted to (remember nothing appears when you type your password, so, don't worry just type it and press enter). Next go to your terminal and stop all mysql instances:

/etc/init.d/mysql stop

after that, go and restart the mysql services (or restart xampp as a whole). This solved my problem. All the best.

allan
  • 111
  • 6
0

If you logged into "phpmyadmin", then logged out, you might have trouble attempting to log back in on the same browser window. The logout sends the browser to a URL that looks like this:

http://localhost/phpmyadmin/index.php?db=&token=354a350abed02588e4b59f44217826fd&old_usr=tester

But for me, on Mac OS X in Safari browser, that URL just doesn't want to work. Therefore, I have to put in the clean URL:

http://localhost/phpmyadmin

Don't know why, but as of today, Oct 20, 2015, that is what I am experiencing.

IAM_AL_X
  • 1,221
  • 11
  • 12
0
sudo service mysql stop

sudo mysqld --skip-grant-tables &

mysql -u root mysql

Change MYSECRET with your new root password

UPDATE user SET Password=PASSWORD('MYSECRET') WHERE User='root'; FLUSH PRIVILEGES; exit;
sjas
  • 18,644
  • 14
  • 87
  • 92
0

If you just installed MySql & PhpMyAdmin you need to alter root password first, otherwise mysql won't let you execute commands and login through PhpMyAdmin also will fail.

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'YourPassword';
Avi L
  • 1,558
  • 2
  • 15
  • 33