Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Connecting To Mysql Using Php


  • Please log in to reply
1 reply to this topic

#1 brennr26

brennr26

  • Members
  • 21 posts
  • OFFLINE
  •  
  • Location:Dublin
  • Local time:08:07 AM

Posted 12 March 2006 - 04:06 PM

Hey!

I'm trying to connect to a mySql database using PHP but I am being denied access to the database.

"--
Warning: mySql_connect(): Access denied for user: 'robbie@localhost' (Using password: YES) in C:\Program Files\Apache Group\Apache2\htdocs\hello.php on line 6
Error connecting to mySql
--"

Here is my PHP
<?php
$dbhost = 'localhost';
$dbuser = 'robbie';
$dbpass = 'password';

$conn = mySql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mySql');

$dbname = 'petstore';
mySql_select_db($dbname);
?>


I created the mySql account like this...
"--
mySql> INSERT INTO user (host, user, password, select_priv, insert_priv, update_priv, delete_priv, create_priv, drop_priv) VALUES ('localhost', 'robbie', 'password', 'Y', 'Y', 'Y', 'Y', 'Y','Y');
Query OK, 1 row affected (0.00 sec)

mySql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)
--"

Does anybody have an idea what is causing the error?

I know that without the FLUSH PRIVILEGES command the user will not be able to connect to the database and after the FLUSH PRIVILEGES command above it says "0 rows affected"!
Does this mean that FLUSH PRIVILEGES command did not take effect?

Thank you for reading!

Edited by brennr26, 12 March 2006 - 04:08 PM.


BC AdBot (Login to Remove)

 


#2 Grinler

Grinler

    Lawrence Abrams


  • Admin
  • 43,622 posts
  • ONLINE
  •  
  • Gender:Male
  • Location:USA
  • Local time:09:07 AM

Posted 23 March 2006 - 06:03 PM

Using mysqladmin you can see if the users exists by doing this:

use mysql;
select * from users


If that row shows the nthe user exists. Also I think you need to give it usage permissions. I manage mysql through phpmyadmin which makes this MUCH easier.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users