错误#1045 - 无法登录MySQL服务器 - > phpmyadmin

问题描述 投票:11回答:10

我们在运行IIS 7.0的Windows机器上安装了PHPMyAdmin。 我们可以使用命令行连接到MySQL,但是我们无法使用PHPMyAdmin进行连接。 显示的错误是:Error #1045 Cannot log in to the MySQL server. 有人可以帮忙吗?

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

编辑: 我按照下面的链接没有成功,意味着我更改了密码,但phpmyadmin仍有错误... C.5.4.1.1. Resetting the Root Password: Windows Systems

还有下面的线程在堆栈中没有帮助: Random error: #1045 Cannot log in to the MySQL server 但那个错误不是随机的 - >我总是有这个错误......

这是phpmyadmin文件夹中的config.inc.php文件:

<?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();
?>

我应该改变这部分代码的哪一部分?

谢谢。

mysql login passwords phpmyadmin windows-server-2008-r2
10个回答
13
投票

按照帖子中提到的链接后,您需要再做两件事:

必须在phpmyadmin config.inc.php中映射更改登录凭据

第二,你需要重新启动你的web和mysql服务器..

php版本不是这里的问题..你需要去phpmyadmin安装目录并找到文件config.inc.php并在该文件中将你当前的mysql密码放在行

$cfg['Servers'][$i]['user'] = 'root'; //mysql username here
$cfg['Servers'][$i]['password'] = 'password'; //mysql password here

0
投票

一些答案;看看这个也;确保没有运行mysql的实例,总是通过不好好结束你的会话。获得超级用户权限

sudo su

并在提示时键入您的密码(记住在您输入密码时不会显示任何内容,因此,请不要担心只需输入密码并按Enter键)。接下来转到终端并停止所有mysql实例:

/etc/init.d/mysql停止

之后,去重新启动mysql服务(或者重新启动xampp)。这解决了我的问题。祝一切顺利。


17
投票

在Linux中,我通过转到root命令提示符类型来解决此问题:

# mysqladmin -u root password 'Secret Phrase Here'

然后返回并登录。每次都有效!


4
投票

如果您是第一次安装,请尝试以root用户名和密码登录


3
投票

一切都没有对我有用的另一件事 - 将config.inc.php中的“localhost”更改为127.0.0.1


2
投票

在mysql 5.7中,auth机制发生了变化,文档可以在官方手册here中找到。

使用系统root用户(或sudo),您可以通过CLI使用mysql“root”用户连接到mysql数据库。所有其他用户也会工作。

然而,在phpmyadmin中,所有mysql用户都可以工作,但不是mysql的“root”用户。

这来自这里:

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

要“修复”此安全功能,请执行以下操作:

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

更多关于这一点也可以在手册中找到here


1
投票

在安全选项卡中更改密码时,有两个部分,一个在上面,一个在下面。我认为这里常见的错误是其他人试图使用他们设置在htaccess所用的“下方”的帐户登录,而他们应该登录他们在上一节中设置的密码。这就是我修复我的方式。


1
投票

对于ubuntu用户,config.inc.php文件应该是这样的

/* 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'] = '';

0
投票

如果您登录“phpmyadmin”,然后注销,则可能无法尝试重新登录同一浏览器窗口。注销将浏览器发送到如下所示的URL:

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

但对我来说,在Safari浏览器的Mac OS X上,该URL只是不想工作。因此,我必须放入干净的URL:

http://localhost/phpmyadmin

不知道为什么,但截至今天,2015年10月20日,这正是我所经历的。


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;
© www.soinside.com 2019 - 2024. All rights reserved.