简体   繁体   English

尝试使用 PHP 脚本连接到 MariaDB 时访问被拒绝

[英]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' 的访问被拒绝(使用密码:否)

Right-Click WAMP icon->select WAMP Settings->Uncheck Mysql and check MariaDB if unchecked, as shown in the attached image.右键单击 WAMP 图标->选择 WAMP 设置->取消选中 Mysql,如果未选中则检查 MariaDB,如附图所示。 After that it works like a charm for me.之后它对我来说就像一个魅力。 允许一个数据库,Mysql 或 MariaDB

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 输入密码:mysqldump:出现错误:1045:尝试连接时用户'XXX'@'localhost'的访问被拒绝(使用密码:NO) - Enter password: mysqldump: Got error: 1045: Access denied for user 'XXX'@'localhost' (using password: NO) when trying to connect 尝试从PHP脚本连接到Redis时排除“权限被拒绝” - Troubleshooting “Permission denied” when attempting to connect to Redis from PHP script 使用PHP时,PSEXEC访问被拒绝 - PSEXEC access denied when using PHP 尝试使用 SSL 从共享主机连接到 Amazon-RDS 实例时出现“拒绝访问”(但在本地测试时有效) - 'Access Denied' when trying to connect to Amazon-RDS instance using SSL from shared hosting (but it works when testing locally) 使用 sha256_password 时如何使用 PHP 的 mysqli 连接到 MySQL(访问被拒绝) - How do you connect to MySQL using PHP's mysqli when using sha256_password (access denied) 与MariaDB的PHP连接错误:错误1045访问被拒绝 - PHP Connection Error to MariaDB: Error 1045 Access Denied 使用PHP脚本将MySQL切换到本地服务器访问被拒绝 - Switching mySQL to local server Access Denied using php script 如何通过ssh使用php连接到MariaDB - How to connect to MariaDB using php over ssh 无法连接:用户php的访问被拒绝 - Could not connect: Access denied for user php PHP中拒绝MySQL访问,CLI将连接 - MySQL access denied in PHP, CLI will connect
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM