gpt4 book ai didi

mysql - 无法连接到我的网站上使用 wamp 创建的数据库

转载 作者:行者123 更新时间:2023-11-29 19:20:42 24 4
gpt4 key购买 nike

我安装了wamp,使其运行,登录http://localhost:8080/phpmyadmin/并创建了一个名为“automobile”的数据库。我制作了自己的网站并且正在运行。但是当我想使用我的数据库时,我却不能。我有这个错误:

警告:mysqli_connect(): (HY000/1045):第 8 行 C:\wamp\www\connect.php 中的用户“root”@“localhost”访问被拒绝(使用密码:YES)

这是我的文件,应该将我连接到我的数据库。

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


?>

最佳答案

您的数据库有密码吗?如果您没有为数据库设置通行证,您将无法连接。

如果您使用 localhost 进行开发,我认为您不需要,现在不需要。您可以直接连接而无需输入密码变量。或者您可以转到数据库管理器,例如 phpMyAdmin 或 mysql workbench 并设置密码。

可能是一个空白密码,例如 $passw = "";

关于mysql - 无法连接到我的网站上使用 wamp 创建的数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42470228/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com