【发布时间】:2017-02-26 15:14:56
【问题描述】:
我安装了 wamp,让它运行,登录 http://localhost:8080/phpmyadmin/ 并创建了一个名为:“automobile”的数据库。我建立了自己的网站,它正在运行。但是当我想使用我的数据库时,我不能。 我有这个错误:
警告:mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES) in C:\wamp\www\connect.php on line 8
这是我应该将我连接到我的数据库的文件。
<?php
$host = "localhost";
$user = "root";
$passw = "root";
$db = "automobile";
$link = mysqli_connect($host, $user, $passw, $db);
// Verificarea conexiunii
if (mysqli_connect_errno()) {
echo "Problema la conectare la baza de date " . mysqli_connect_error();
}
else {
//echo "Conectare cu succes la baza de date <br>";
}
?>
这是来自 WAMP 的 config.inc 文件:
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* phpMyAdmin sample configuration, you can use it as base for
* manual configuration. For easier setup you can use setup/
*
* All directives are explained in documentation in the doc/ folder
* or at <http://docs.phpmyadmin.net/>.
*
* @package PhpMyAdmin
*/
/*
* This is needed for cookie based authentication to encrypt password in
* cookie
*/
$cfg['blowfish_secret'] = 'a8b7c6d'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
/*
* Servers configuration
*/
$i = 0;
/*
* First server
*/
$i++;
/* Authentication type */
$cfg['Servers'][$i]['verbose'] = 'localhost';
$cfg['Servers'][$i]['auth_type'] = 'cookie';
//$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'root';
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
/* Select mysql if your server does not have mysqli */
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
$cfg['Servers'][$i]['port'] = 3307;
/*
* phpMyAdmin configuration storage settings.
*/
// No warning on pmadb tables
$cfg['PmaNoRelation_DisableWarning'] = true;
?>
【问题讨论】:
-
尝试使用 127.0.0.1 而不是 localhost
-
我试过了。不工作。