如何解决1045错误

时间:2017-10-22 19:55:07

标签: phpmyadmin

重现的步骤

我在MAMP上运行phpMyAdmin。 MySQL运行正常。但是它无法通过显示

的phpMyAdmin连接MySQL
  

mysqli_real_connect():( HY000 / 1045):拒绝访问用户' root' @' localhost' (使用密码:是)

使用相同的用户(root)和密码(poiu)在MySQL工作台上运行良好。

Operating system:
MacOS 10.12.6
Web server: MAMP
Database: MySQL 5.7.2
PHP version: 7.1.1
phpMyAdmin version: 4.4.4

config.inc.php文件:

$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'] = 'cookie';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'poiu';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
$cfg['DefaultLang'] = 'en';
$cfg['ServerDefault'] = 1;
$cfg['UploadDir'] = '';
$cfg['SaveDir'] = '';
$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';

我认为密码的设置是正确的。如何访问phpMyAdmin?

顺便说一句,'auth_type'设置为'cookie'。我尝试更改此值,但如果我这样做,它也会显示error 1045,但甚至无法获取登录窗口。

1 个答案:

答案 0 :(得分:0)

因此您需要通过更改AllowNoPassword设置的行来将其设置为使用密码:

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