Cant connect to mysql by setting credentials in php code
Posted by: lester (---.209.7.10.pldt.net)
Date: February 03, 2016 04:30PM

Hi Team,

Just installed wamp server 2.1 on Windows 7.
It includes Apache 2.2.1.7, mysql 5.1.53 and php 5.3.4.
I checked the wampserver icon and it is green.

My problem is, I cannot connect to the mysql server using php code. It always saying Warning: mysqli_connect(): (28000/1045): Access denied for user 'fpi'@'localhost' (using password: YES)
I created a user using sqlbuddy and it generated its own password using the password I specify for my new user.
Either the password I specified nor the password it generated using the password I specified did not work if I put them as parameters in below codes:

$conn = mysqli_connect("localhost", <my_new_user_here>, <password>winking smiley;

All privileges were granted upon creation of the new user.

In my host file, this is the only active line
127.0.0.1 localhost

I am able to access the phpmyadmin page but maybe it uses the default credentials.
I verified that my new user and password(the generated password by sqlbuddy) is working by logging in in the sqlbuddy.



Please let me know what else did I missed, I am a newbie in wampserver.
Or if there was solved before, please refer me to the link.

Thanks in advance.

Options: ReplyQuote
Re: Cant connect to mysql by setting credentials in php code
Posted by: RiggsFolly (---.dynamic.dsl.as9105.com)
Date: February 03, 2016 07:32PM

First try this

Username = 'root'
Password = '' i.e. empty

This is the Super user account.

Then:

mysqli_connect has 4 parameter See the manual the 4th parameter being the name of the database to connect to.

If you are converting mysql_ to mysqli_ it is not a 1<=> 1 relationship.


Then try your newly created userid/password if it still does not work, you did something wrong

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote


Sorry, only registered users may post in this forum.