PHP MYSQL数据库连接无法正常工作? [英] PHP MYSQL database connection not working?

查看:64
本文介绍了PHP MYSQL数据库连接无法正常工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑到问题的简单性,这可能是一个愚蠢的问题,但无论如何我无法弄明白。

所以我的问题是的,我只是想连接到我的phpmyadmin数据库。我在成功之前已经完成了这项工作,但出于某种原因,这次它无法正常工作。这是我的代码:



$ con = mysqli_connect(localhost,root,,nz_games);

if(mysqli_connect_errno()){

echo无法连接到MySQL:。 mysqli_connect_error();

}

?>



这里的错误:

无法连接到MySQL:用户root@localhost拒绝访问(使用密码:否)



据我所知,没有密码到我的数据库,phpmyadmin的默认用户名应该是root,我的表名是nz_games。请帮助!!

This is probably a dumb question considering the simplicity of my problem but I can't figure it out anyway.
So my problem is, I am simply trying to connect to my phpmyadmin database. I have done this before successfully but for some reason, this time it is not working. Here is my code:

$con = mysqli_connect("localhost","root","","nz_games");
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
?>

And here the error:
Failed to connect to MySQL: Access denied for user 'root'@'localhost' (using password: NO)

As far as I know there is no password to my database, the default username for phpmyadmin should be root and my table name is nz_games. Please Help!!

推荐答案

con = mysqli_connect(localhost,root,,nz_games);

if(mysqli_connect_errno()){

echo无法连接到MySQL:。 mysqli_connect_error();

}

?>



这里的错误:

无法连接到MySQL:用户root@localhost拒绝访问(使用密码:否)



据我所知,没有密码到我的数据库,phpmyadmin的默认用户名应该是root,我的表名是nz_games。请帮忙!!
con = mysqli_connect("localhost","root","","nz_games");
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
?>

And here the error:
Failed to connect to MySQL: Access denied for user 'root'@'localhost' (using password: NO)

As far as I know there is no password to my database, the default username for phpmyadmin should be root and my table name is nz_games. Please Help!!


试试这段代码



Try this code

if(mysql_connect("localhost","root","password"))
{
   echo "Successfully connected";
}
?>


这篇关于PHP MYSQL数据库连接无法正常工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆