<?php
$db = mysqli_connect('localhost','root','','firstdb')
or die('Error connecting to MySQL server.');
?>
<html>
<head>
</head>
<body>
<h1>PHP connect to MySQL</h1>
</body>
</html>
尽管错误为“拒绝访问用户'username'@'localhost'”,但我似乎无法访问我的文件,因为我对没有密码的根用户的访问被拒绝。
我也试着用用户名“username”创建一个用户,但根本不起作用。
1条答案
按热度按时间svgewumm1#
代码没有问题。
我正在编辑一个php文件,其文件名与我尝试连接的文件名相同