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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting up users in MySQL (newbie Q)

Status
Not open for further replies.

wreikun

Technical User
Apr 23, 2002
63
US
Im a bit confused on how to set up users and connect to the mysql server using this newly made user. According to a book Im learning from, creating a user involves the following lines:

GRANT [privileges]
ON [database_name]
TO [user_name]
IDENTIFIED BY '[password]';

Im running mysql 3.23.49a on a TurboLinux 6.5 server. After starting up the mysql server I enter the following:

GRANT all
ON database1.*
TO user1
IDENTIFIED BY 'password1';

Now when I have the following line in a php file:

/* LINE 7 */
mysql_connect("localhost", "user1", "password1");
/* LINE 8 */
mysql_select_db("database1");

I get the following displayed in my browser:

Warning: Access denied for user: 'user1@localhost' (Using password: YES) in /home/user1/public_html/script.php on line 7

Warning: MySQL Connection Failed: Access denied for user: 'user1@localhost' (Using password: YES) in /home/user1/public_html/script.php on line 7
couldnt connect to mysql

Why does the connection fail even after I create a user through mysql? Does 'user1' have to exist as a user on my Linux server? or can I create 'user1' as as username on mysql even if this username doesnt exist on my Linux server?
Im not able to get the grasp of how to create usernames and using these to connect to the mysql server.

Any help is appreciated! Thanks!

--REI
 
try to run "FLUSH PRIVILIGES" on the server or restart mysql
 
Hello. I entered 'flush privileges' and then tried to run the php script once again but with the same results as before. What does the 'flush privileges' command do exactly?

Thanks,
REI
 
nevermind! i got it working! thanks for the help.

regards,
REI
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top