我安裝了wamp,使其運行,登錄到http://localhost:8080/phpmyadmin/並創建了一個名爲「automobile」的數據庫。我創建了自己的網站並且正在運行。但是當我想使用我的數據庫時,我不能。 我有這樣的錯誤:無法連接到使用wamp創建的我的網站上的數據庫
警告:mysqli_connect():(HY000/1045):在C:訪問被拒絕的用戶 '根' @ '本地主機'(YES使用密碼):\瓦帕\ WWW \連接。第8行的php
這是我的文件,應該將我連接到我的數據庫。
<?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>";
}
?>
這裏是config.inc文件從WAMP:
<?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而不是本地主機 –
我試過了。不工作。 –