jimczerniak at August 19th, 2013 13:26 — #1
I have a simple .php file with the following to connect to MySQL. However, I get the following error...
Could not connect: Access denied for user 'some_user'@'localhost' (using password: YES)
I reviewed the following post from about a year ago, but it doesn't appear to have a resolution. Has anybody else ran into this problem???
// Create connection
$username = "some_user";
$password = "password";
$host = "localhost";
$database = "some_db";
// Check connection
echo "Failed to connect to MySQL: " . mysqli_connect_error();
kaysa at August 20th, 2013 04:25 — #2
Can you connect as root? You can check the users that are allowed to connect to that server checking the user table in the 'mysql' database.
For giving permissions to some_user to localhost you will need to execute:
GRANT ALL PRIVILEGES ON test.* TO 'username'@'localhost' IDENTIFIED BY 'password';
(where 'test' is the database to which you want to give access to the user)
jimczerniak at August 20th, 2013 10:02 — #3
Hmmm, I was going to try your solution but before I could I am now getting the following error when I try to connect via PHP.....Failed to connect to MySQL: No connection could be made because the target machine actively refused it. I can login to PHPMYADMIN just fine though. I believe some Windows updates got installed last night so I hope that didn't end up breaking it. Has anyone ran into this problem before?? Thanks in advance for any help in getting this connected.
kaysa at August 20th, 2013 12:00 — #4
Didn't you changed anything? Is mysql server running? Was your machine running locally or were you connecting to a remote machine?
jimczerniak at August 20th, 2013 12:56 — #5
Nothing was changed. Unless those Windows updates messed with something. MySQL is running and everything is running locally. Any ideas?? I still haven't figured it out.
jimczerniak at August 20th, 2013 16:30 — #6
I uninstalled the Windows updates from the previous evening and still getting the error...No connection could be made because the target machine actively refused it. I also checked to make sure my Windows Firewall is disabled. I am running out of things to check....I'm hoping someone has run into this issue before. I am contemplating re-installing everything, which I don't want to do.
kaysa at August 21st, 2013 06:26 — #7
Ok so, you can connect to MySQL using phpMyAdmin (the one included with BitNami), right? But you cannot connect using php using the command line. What are you exactly executing? Are you passing the path to php.ini when executing php from the command line?
jimczerniak at August 21st, 2013 09:26 — #8
I decided to uninstall and re-install everything. Now that everything is re-installed it connects no problem with the root user. Thanks for your help, even though I am still not sure what was causing the issue before. It seems to be fixed now.