Hi

I'm pretty new at MySQL, so I have a question about setting up a new user. Currently, I'm working on a Guestbook, which will have an Admin section to set up the lay out of the book (and delete unwanted messages). In my opinion, I will need two new users (apart from the root user, which I must only use to set up the new accounts):

  1. Admin, a user as described above.
  2. Webvisitor, a user with only INSERT privileges, to use online so one can enter a new message in the guestbook.

But here's the thing: I'm not sure how to set up these users so I can also connect to the database with them. For instance, if I want to set up the Webvisitor account, I'll do the following:

GRANT INSERT ON tables.* TO webvisitor IDENTIFIED BY 'webpassword';

However, this will not allow me to connect to the database, either via PHP or via the MySQL program:

$mysql=mysql_connect(localhost,webvisitor,webpassword);
or
mysql -u webvisitor

I still need to use "root" to do this. Does anyone know how I can solve this? The following page lists the GRANT possibilities, but none of them seem to fit the purpose:

http://www.mysql.com/doc/en/GRANT.html

Thanks!
Stille

    as i remember FLUSH PRIVILEGES must to be executed after any changes to user tables

      Thanks for the quick reply. Flushing the privileges doesn't seem to help.

      When I use the GRANT option as I described above, should that automatically give that user the possibility to connect to the dbase?

        it MUST work.

        check sintax, if not, try to add user manually, like this

        INSERT INTO mysql.user SET Host = 'localhost', User = 'webvisitor', Password = PASSWORD('webpass'), Select_priv = 'Y', Insert_priv = 'Y', Update_priv = 'N', Delete_priv = 'N', Create_priv = 'N', Drop_priv = 'N', Reload_priv = 'N', Shutdown_priv = 'N', Process_priv = 'N', File_priv = 'N', Grant_priv = 'N', References_priv = 'N', Index_priv = 'N', Alter_priv = 'N'

        (dont forget about FLUSH)

          OK, I found the problem. Due to bad coding on my part, I first encrypted the password of webvisitor, then granted access on webvisitor with the encrypted password, but tried to connect with the unencrypted one.

          D'oh!!

          Well, at least I've learned something new 🙂

          Now if you'll excuse me, I'll be off to kick myself in the head a couple o' times... 🙁😃

            Write a Reply...