我在某个名为“ freewebhostingarea.com”的免费托管网站上托管了一个网站,并且对于该特定项目,当我在Apache上本地运行该网站时,它的运行情况还不错,但是当我将其上传到服务器时,我无法访问同一数据库托管在我家里的计算机上。因此,最初,我使用phpmyadmin作为DBMS在WAMPP下运行该站点,但是当我移动该站点时,我将.sql文件从phpmyadmin导入到Workbench中,并提供了对root帐户的外部访问权限,并对此进行了测试,因此我可以通过来自另一台计算机的Internet。但是网站本身如果给出此错误:
用户'apache'@'localhost'的访问被拒绝(使用密码:否)
但是访问数据库的脚本具有以下代码:
<?php
mysqli_connect('url','username','password');
echo mysql_error();
mysql_select_db('database');
echo mysql_error();
?>
指定我要使用的用户名时,为什么我什至不理解为什么甚至使用“ apache”作为用户名?
最佳答案
用这个
Go to this page and found your mysql username and password
<?php
$usernmae = '996869';
$password = '996869';
$dbname = '996869';
$db_conx = mysqli_connect("localhost", "root", "", "project2");
if (mysqli_connect_error()) {
echo mysqli_connect_error();
exit();
}
?>