我安装了 wamp server2,它没有密码,并且出现下面这个错误,然后我转到 mysql 并使用此命令为 root 设置密码,我可以使用此密码登录,但我再次无法访问 phpmyadmin。我也重新启动了服务。
update user.mysql set password=password('root') where user='root';
然后我去 config.inc 将密码改为这个:
$cfg['Servers'][$i]['password'] = 'root';
我再次重新启动,但仍然没有结果。
phpmyadmin 页面:
Welcome to phpMyAdmin
Error
MySQL said: Documentation
#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.
配置.inc:
<?php
/* Servers configuration */
$i = 0;
/* Server: localhost [1] */
$i++;
$cfg['Servers'][$i]['verbose'] = 'localhost';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['port'] = '';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'root';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
/* End of servers configuration */
$cfg['DefaultLang'] = 'en-utf-8';
$cfg['ServerDefault'] = 1;
$cfg['UploadDir'] = '';
$cfg['SaveDir'] = '';
/* rajk - for blobstreaming */
$cfg['Servers'][$i]['bs_garbage_threshold'] = 50;
$cfg['Servers'][$i]['bs_repository_threshold'] = '32M';
$cfg['Servers'][$i]['bs_temp_blob_timeout'] = 600;
$cfg['Servers'][$i]['bs_temp_log_threshold'] = '32M';
?>
首先将此行$cfg['Servers'][$i]['password'] = '';
设置允许为 false,重新启动也不会改变错误,在 Erika 的帮助下,我明白它无法读取 confg.inc 文件,如何让它从该文件中读取?
答案1
#1045 - Access denied for user 'root'@'localhost' (using password: NO)
PHPMyAdmin 正在尝试在没有密码的情况下进行身份验证。
您可能需要将以下内容更改为false
:
$cfg['Servers'][$i]['AllowNoPassword'] = true;
答案2
安装脚本将配置文件 config.inc.php 保存到 [phpmyadmindir]/config。我将其移动到 phpmyadmin 的根目录,这样就成功了。
答案3
在您的 config.inc 中更改
$cfg['Servers'][$i]['host'] = 'localhost';
为
$cfg['Servers'][$i]['host'] = '127.0.0.1';
或者设置套接字路径。使用 TCP 连接时,需要提供 IP 地址。