[英]Access denied when trying to connect to MariaDB using PHP script
I have WAMPServer 3.2.6 on Windows 10 (64bit), and I'm able to connect to MariaDB using phpMyAdmin without any problem.我在 Windows 10(64 位)上有 WAMPServer 3.2.6,我可以使用 phpMyAdmin 毫无问题地连接到 MariaDB。
Now I want to connect the database with same user account by running php script instead.现在我想通过运行 php 脚本来连接具有相同用户帐户的数据库。
Here is relevant part of my script file, test.php:这是我的脚本文件 test.php 的相关部分:
$servername = "localhost";
$dbname = "xdurxttx_gromates";
$username ="root"; //"xdurxttx_gromates";
$password =""; //"gromatespassword";
// Create connection. Following line causes the "access denied" error
$conn = new mysqli($servername, $username, $password, $dbname);
I also tried a regular db user account, xdurxttx_gromates, and the result was the same.我还尝试了一个普通的 db 用户帐户 xdurxttx_gromates,结果是一样的。
I would greatly appreciate it if someone could give me some hint, guiding me to the right direction.如果有人能给我一些提示,引导我走向正确的方向,我将不胜感激。
Thanks in advance.提前致谢。
toby托比
Exact Error Message: :)确切的错误消息::)
Warning: mysqli::__construct(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: NO) in D:\Data\b4a\apps\gromates\deedeegroup.com\root\public_html\gromate\php\testgromate.php on line 23
警告:mysqli::__construct(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: NO) in D:\Data\b4a\apps\gromates\deedeegroup.com\root\ public_html\gromate\php\testgromate.php 在第 23 行
Call Stack # Time Memory Function Location 1 0.0015 362400 {main}( ) ...\testgromate.php:0 2 0.0015 362784 __construct( $host = 'localhost', $user = 'root', $password = '', $database = 'xdurxttx_gromates' ) ...\testgromate.php:23 Connection failed: Access denied for user 'root'@'localhost' (using password: NO)调用堆栈 # 时间记忆函数位置 1 0.0015 362400 {main}( ) ...\testgromate.php:0 2 0.0015 362784 __construct( $host = 'localhost', $user = 'root', $password = '', $数据库 = 'xdurxttx_gromates' ) ...\testgromate.php:23 连接失败:用户 'root'@'localhost' 的访问被拒绝(使用密码:否)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.