[SOLVED] Do I need USER account in MySQL db for PHP query?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
Calimero
Forum Contributor
Posts: 310
Joined: Thu Jan 22, 2004 6:54 pm
Location: Milky Way

[SOLVED] Do I need USER account in MySQL db for PHP query?

Post by Calimero »

Hello,
//*This my first POST here, so
IF (I make an error)
THEN (Please forgive me)
ELSE (Tell me how to avoid making one in the future)

WHILE (I was working on my Search Eng.
I screened a lot of PHP-scripts but still I dont know how the language functions, However I have medium knowledge of MySQL
[b]So I encountered a problem,
Whenever PHP script queryies mysql_db there is a part of the code concerning: host, user and pass
in the exapmles those were usualy localhost, -u, -p.
MY QUESTION - DO I NEED TO MAKE NEW USER IN THE DATABASE - DB IS ON MY HOSTING PROVIDERS SITE ( AND I GOT PASSWORD TO MANAGE IT ), AND GRANT HIM (USER) SOME PRIVILEDGES AND RELATED STUFF, OR DO I JUST QUERY DB WITH PHP. MY CONCERN IS THAT NO ONE WILL BE ALLOWED TO INSERT - UPDATE - DELETE - DROP SOMETHING IN THE DATABASE, AND I DONT UNDERSTAND IF THE PHP CAN DO IT, WHY CANT SOMEONE FROM THE INTERNET DO THE SAME THING - JUST ALTER THE CODE AND MAKE ME SUFFER :)[/b]
I already have some books on PHP, BUT they just tell about some segments of PHP, I can't learn logic of the language from them - And I see that PHP and MySQL logic differs considerably.

THANKS AHEAD... AND IF POSSIBLE REPLY TO THIS AS SOON AS POSSIBLE, BECAUSE I MUST FINISH THIS IN TWO WEEKS. :)
Last edited by Calimero on Sun Jan 25, 2004 8:47 am, edited 1 time in total.
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Yes, you need to use the mysql username and password the host has supplied.
You also appear to have a broken caps lock key :o
User avatar
Calimero
Forum Contributor
Posts: 310
Joined: Thu Jan 22, 2004 6:54 pm
Location: Milky Way

So how do I grant my PHP script access to query DB

Post by Calimero »

I have MySQL db, I will write php scripts that will query db, but how do I grant permission to PHP scripts to query (SELECT, INSERT, DELETE) db, but no one else can be allowed to do so.
I know about GRANT command in MySQL,
GRANT <privileges> ON <database> TO <user> [IDENTIFIED BY <password> ------- HOW to edit <user> and INDENTIFIED BY commands to adapt them to php query (is thios done in the PHP or mysql

Thanks
markl999 for the answer

And thanks ahead for the next one :D
Post Reply