[英]Cannot connect Xampp server with PHP script
I granted all privileges. 我授予了所有特权。 This is the script:
这是脚本:
<?php
require_once 'login.php';
$conn = new mysqli($hn, $un, $pw, $db);
if ($conn->connect_error) die($conn->connect_error);
?>
I have this message in the browser: 我在浏览器中有此消息:
Warning: mysqli::mysqli(): (HY000/1045): Access denied for user 'username'@'localhost' (using password: YES) in C:\\xampp\\htdocs\\web-datos\\connect_mysql.php on line 11
警告:mysqli :: mysqli():(HY000 / 1045):在第11行的C:\\ xampp \\ htdocs \\ web-datos \\ connect_mysql.php中,用户'username'@'localhost'的访问被拒绝(使用密码:是)
Access denied for user 'username'@'localhost' (using password: YE
用户'username'@'localhost'的访问被拒绝(使用密码:YE
I've tried to connect with no success. 我尝试连接失败。
How can I solve this problem? 我怎么解决这个问题?
i believe you cannot connect to your mysql database. 我相信您无法连接到mysql数据库。 you need to grant access to username@localhost.
您需要授予对username @ localhost的访问权限。
grant all privileges on yourdb.* to username@localhost identified by 'password';
if you have not created the user.you can use this command to create new user. 如果尚未创建用户,则可以使用此命令来创建新用户。
create user 'newuser'@'localhost' identified BY 'password';
you could also possibly type your user or password wrong.please check it 您也可能输入了错误的用户名或密码。请检查一下
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.