Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cannot connect to MYSQL from PHP

Status
Not open for further replies.

leegold

Technical User
Mar 19, 2002
39
US
I can connect in the php by using 'root' and the root pw. But when I tried adding a user ( sarah ) with GRANT I cannot connect from php. The php is simple, what am I overlooking? Again putting the root user name and pw it'll work in php but not for sarah:

the php....
mysql_pconnect("localhost","sarah","camera")
or die("ERROR: Could not connect to database!");
mysql_select_db("howto");

But on the command line the sarah user works OK:

C:\Documents and Settings\Administrator>mysql -u sarah -p
Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 19 to server version: 4.1.3a-beta-nt-max

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> select * from howto.page;
+---------+-----------------------------+
| page_id | page_url |
+---------+-----------------------------+
| 1 | |
+---------+-----------------------------+
1 row in set (0.00 sec)

mysql> show grants for sarah@localhost;
+-----------------------------------------------------------------------------------------------------------------------+
| Grants for sarah@localhost |
+-----------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'sarah'@'localhost' IDENTIFIED BY PASSWORD '*6043233C67ADBE7E9242089D718763C3C5E1A1E2' |
+-----------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql>
 
Are you sure the password got input correctly? have you tried changing the password and re-attempting the connection?

Bastien

Cat, the other other white meat
 
After adding the user to MySQL did you isse a reload of the privilege tables:
Code:
mysql>flush privileges;
If you don't do that the new privilege will not be considered.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top