"Connect failed: Access denied for user 'root'@'localhost' (using password: YES)" from php function

Viewed 739991

I wrote some function used by a php webpage, in order to interact with a mysql database. When I test them on my server I get this error:

"Connect failed: Access denied for user 'root'@'localhost' (using password: YES)" 

I am able to use them on my pc (using XAMPP) and I can navigate through the tables of the database using the command line in the server. However, the webpage fails to connect. I've checked the password but with no results. It's correct (otherwise I could not log in to mysql from the command line).

The call of the function is the following:

$conn = new mysqli("localhost", "root", "password", "shop");

Do I have to set something in my server? Thanks

Edit: PHP version 5.3.3-7+squeeze1 mysql version: 5.1.49-3 both on debian

11 Answers

Easy.

open xampp control panel -> Config -> my.ini edit with notepad. now add this below [mysqld]

skip-grant-tables

Save. Start apache and mysql.

I hope help you

May be there password is not set and you are passing password as argument. Try ommitting password argument during connection..

Related