简体   繁体   中英

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.

Now I want to connect the database with same user account by running php script instead.

Here is relevant part of my script file, 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.

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
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)

Right-Click WAMP icon->select WAMP Settings->Uncheck Mysql and check MariaDB if unchecked, as shown in the attached image. After that it works like a charm for me. 允许一个数据库,Mysql 或 MariaDB

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM