Cannot connect to the mysql database in apache

Alles, was MariaDB und MySQL betrifft, kann hier besprochen werden.

Cannot connect to the mysql database in apache

Postby jerrittpace » 14. November 2015 19:05

I cannot access the mysql database using apache

I am using the simple code to allow this to test, which is unsuccessful:

<?php

// Connect Test

echo 'TEST';

mysql_connect("127.0.0.1", "host" , "users", "553597") or die(mysql_error());
mysql_select_db("users") or die(mysql_error());

?>

I am getting the following error:

Warning: mysql_connect(): Access denied for user 'host'@'localhost' (using password: YES) in C:\xampp\htdocs\New folder (5)\test.php on line 16
Access denied for user 'host'@'localhost' (using password: YES)

I have tried changing the password for both the host user and new user accounts I have created using the localhost:8080/phpMyadmin tools.
as well as tried changing the config.inc.php $cfg['Servers'][$i]['password'] = ''; value, which only caused me to be unable to access the phpMyadmin.
I am using host 8080.

I cannot find any help for this in the forums, as I have tried all the solutions i have found, to no avail...

Thank you for any help you can offer
jerrittpace
 
Posts: 26
Joined: 14. November 2015 18:54
Operating System: windows

Re: Cannot connect to the mysql database in apache

Postby Altrea » 14. November 2015 19:17

Take a step back and check the function description: http://php.net/manual/en/function.mysql-connect.php

compare the parameters with the parameters you have given.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8293
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: Cannot connect to the mysql database in apache

Postby jerrittpace » 14. November 2015 19:47

This is what i am using, still with errors...

mysql_connect("127.0.0.1", "host" , "553597") or die(mysql_error());
jerrittpace
 
Posts: 26
Joined: 14. November 2015 18:54
Operating System: windows

Re: Cannot connect to the mysql database in apache

Postby Altrea » 14. November 2015 19:48

jerrittpace wrote:This is what i am using, still with errors...

mysql_connect("127.0.0.1", "host" , "553597") or die(mysql_error());


So you do have a user "host@127.0.0.1" with the password "553597"?
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8293
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: Cannot connect to the mysql database in apache

Postby jerrittpace » 14. November 2015 20:37

Yeah I've tried a couple variations of setting up different users, and then just using the host user name... I've tried turning off the password in the phpMyadmin on the various user names.

I think it's a problem accessing the database, and not the code itself (i didn't realize the function was deprecated, but I don't think that is the problem, is that right?) due to the warning I'm getting:

Warning: mysql_connect(): Access denied for user 'host'@'localhost' (using password: YES) in C:\xampp\htdocs\New folder (5)\test.php on line 16
Access denied for user 'host'@'localhost' (using password: YES)

I tried changing the password inside the password inside the config.inc.php

$cfg['Servers'][$i]['password'] = ''; to
$cfg['Servers'][$i]['password'] = '553597';

That only had the effect of blocking me out of the phpMyadmin control panel

To be honest, I'm not sure what to do now, so I really appreciate your help

Sorry about the misprinted code originally
jerrittpace
 
Posts: 26
Joined: 14. November 2015 18:54
Operating System: windows

Re: Cannot connect to the mysql database in apache

Postby jerrittpace » 14. November 2015 20:40

Oh for instance, I have a user 'jerrittpace' password '553597', so the code I've tried with that user name is

<?php
// Connect Test

echo 'TEST';

mysql_connect("127.0.0.1", "jerrittpace", "553597") or die(mysql_error());
mysql_select_db("users") or die(mysql_error());

?>

Which gets the same warning:

Warning: mysql_connect(): Access denied for user 'jerrittpace'@'localhost' (using password: YES) in C:\xampp\htdocs\New folder (5)\test.php on line 16
Access denied for user 'jerrittpace'@'localhost' (using password: YES)
jerrittpace
 
Posts: 26
Joined: 14. November 2015 18:54
Operating System: windows

Re: Cannot connect to the mysql database in apache

Postby jerrittpace » 14. November 2015 20:41

I'm using port 8080, is that the problem?
jerrittpace
 
Posts: 26
Joined: 14. November 2015 18:54
Operating System: windows

Re: Cannot connect to the mysql database in apache

Postby Altrea » 14. November 2015 21:08

jerrittpace wrote:(i didn't realize the function was deprecated, but I don't think that is the problem, is that right?)

It will be a problem with PHP 7 which will get released in a few days. So maybe you should start now to change to mysqli or pdo.

jerrittpace wrote:Warning: mysql_connect(): Access denied for user 'host'@'localhost' (using password: YES) in C:\xampp\htdocs\New folder (5)\test.php on line 16
Access denied for user 'host'@'localhost' (using password: YES)

Which simply means that there is no user host@localhost or the password you tried is not correct.
So how did you set the password?

jerrittpace wrote:I tried changing the password inside the password inside the config.inc.php

$cfg['Servers'][$i]['password'] = ''; to
$cfg['Servers'][$i]['password'] = '553597';

Forget this. Leave this as it was before. This has nothing to do with your problem.

jerrittpace wrote:I'm using port 8080, is that the problem?

You are using port 8080 for Apache not for MySQL, is that right? Than this is not a problem. Just keep in mind that you need to access phpmyadmin with the 8080 added to the url, so for example http://localhost:8080/phpmyadmin/
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8293
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: Cannot connect to the mysql database in apache

Postby jerrittpace » 14. November 2015 21:11

I'm getting the same error with the $mysqli funtion:


<?php
$mysqli = new mysqli("127.0.0.1", "root", "553597", "users");
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
?>

Warning: mysqli::mysqli(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES) in C:\xampp\htdocs\New folder (6)\test.php on line 11
Failed to connect to MySQL: (1045) Access denied for user 'root'@'localhost' (using password: YES)

You know, when I turn the password off in phpMyAdmin, I am not getting the error message, but I cannot make this work when the password is on.

I appreciate your help and expression that the password is incorrect, but I am very confident this is not the case. I have tried changing the password, and I just can't get through with the password active in phpMyAdmin.

I really appreciate your help!
jerrittpace
 
Posts: 26
Joined: 14. November 2015 18:54
Operating System: windows

Re: Cannot connect to the mysql database in apache

Postby jerrittpace » 14. November 2015 21:14

I set the password in phpMyadmin, by both clicking, the "change admin" link, as well as just deleting the user ('jerrittpace', not the host user though) and creating it fresh.

I am fairly confident I have created the user with the '553597' password.
jerrittpace
 
Posts: 26
Joined: 14. November 2015 18:54
Operating System: windows

Re: Cannot connect to the mysql database in apache

Postby Altrea » 14. November 2015 21:22

I am confused now.
Is your username "root" or "host?
You jump from one to another...
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8293
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: Cannot connect to the mysql database in apache

Postby jerrittpace » 14. November 2015 21:25

I'm sorry you're right it's root...

I changed the password for the root user name inside the phpMyadmin and now I am locked out... I don't know how to change this back to get back in
jerrittpace
 
Posts: 26
Joined: 14. November 2015 18:54
Operating System: windows

Re: Cannot connect to the mysql database in apache

Postby Altrea » 14. November 2015 21:27

If you change the password for user root you must set this in the config.inc.php of phpmyadmin too.
Thats just for the login to phpmyadmin and only needed for this specific user root.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8293
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: Cannot connect to the mysql database in apache

Postby jerrittpace » 14. November 2015 21:32

Listen I really appreciate the help... honestly I don't kow why the original user name 'jerrittpace' was not working, but it is now.

I was able to change the config.inc.php to allow me back in, and I don't really know what I was doing wrong, but it has apparently abated, and I really appreciate your help! Cheers!
jerrittpace
 
Posts: 26
Joined: 14. November 2015 18:54
Operating System: windows


Return to MariaDB - MySQL

Who is online

Users browsing this forum: No registered users and 7 guests