Error # 1045 - Cannot Log in to MySQL server -> phpmyadmin
Asked Answered
S

11

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.

Splenic answered 13/11, 2012 at 8:30 Comment(0)
C
15

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
Crouch answered 13/11, 2012 at 9:1 Comment(9)
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?Splenic
i guess you have pasted code of phpmyadmin's index.php..i have updated my answer..pls check..Crouch
thanks for the edit -> but i do n't have these lines in that file -> please see my edit again.Splenic
no, it's config.inc.php file -> i 've downloaded from here -> sourceforge.net/projects/phpmyadmin/files/phpMyAdmin/3.5.4-rc1/…Splenic
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..Crouch
is it giving the same error..??have you restarted your web server..??Crouch
mmmmmmm i restarted my iis, please wait... now i restarted my web server -> still does not work -> what is this damn error?Splenic
let us continue this discussion in chatCrouch
This solution is wrong. It doesn't do anything.Awhirl
E
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!

Endowment answered 26/6, 2013 at 9:44 Comment(2)
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.shForecourse
Nope. mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: NO)' Awhirl
C
15

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
Crouch answered 13/11, 2012 at 9:1 Comment(9)
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?Splenic
i guess you have pasted code of phpmyadmin's index.php..i have updated my answer..pls check..Crouch
thanks for the edit -> but i do n't have these lines in that file -> please see my edit again.Splenic
no, it's config.inc.php file -> i 've downloaded from here -> sourceforge.net/projects/phpmyadmin/files/phpMyAdmin/3.5.4-rc1/…Splenic
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..Crouch
is it giving the same error..??have you restarted your web server..??Crouch
mmmmmmm i restarted my iis, please wait... now i restarted my web server -> still does not work -> what is this damn error?Splenic
let us continue this discussion in chatCrouch
This solution is wrong. It doesn't do anything.Awhirl
C
5

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

Cheekbone answered 3/11, 2013 at 9:23 Comment(0)
F
4

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

Faithless answered 13/8, 2015 at 18:47 Comment(1)
This doesn't fix the problem.Awhirl
M
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.

Madeira answered 7/6, 2016 at 18:25 Comment(1)
If this once worked, it no longer does. ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO).Awhirl
U
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'] = '';
Uncertainty answered 3/2, 2017 at 7:33 Comment(0)
I
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.

Intercut answered 3/8, 2015 at 14:42 Comment(0)
F
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.

Faxun answered 20/3, 2019 at 10:21 Comment(0)
T
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.

Tatianna answered 20/10, 2015 at 17:26 Comment(0)
F
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;
Fall answered 4/4, 2016 at 6:36 Comment(0)
S
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';
Sackville answered 27/6, 2023 at 17:56 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.