SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Jan 2006
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Created new user but can't login

    I'm using the Build your own Database Driven Website using PHP & MySQL to help me learn PHP & mySQL (obviously).

    I wanted to create a new user that had limited access to MySql server that I could use in my login.inc.php file. I don't want to use root incase anyone manages to get hold of the login details then they can do what they want to my database.

    I created a new user with the following rights delete, insert, lock tables, select, update and file on a specific database.

    I used the following command to grant the access setting the user up to be able to login from any computer (I think):

    grant privilege on db.*
    to user@"%"
    identified by 'password';

    When I exit mysql and try and log back in using the new users details:

    mysql -h localhost -u user -p
    password

    I get the following error:
    Access denied for user 'user'@'localhost' (using password: YES)

    When I put the details in my login.inc.php file it also doesn't allow access to the database.

    Can anyone please help?

  2. #2
    Tranceoholic lilleman's Avatar
    Join Date
    Feb 2004
    Location
    Írebro, Sweden
    Posts
    2,716
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You have to reload the privileges to be able to use the new user. This is done by running the query FLUSH PRIVILEGES.
    ERIK RIKLUND :: Yes, I've been gone quite a while.

  3. #3
    SitePoint Member
    Join Date
    Jan 2006
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the quick reply, but I just tried FLUSH PRIVILEGES and I still can't login as my new user.

  4. #4
    _ silver trophy ses5909's Avatar
    Join Date
    Jul 2003
    Location
    NoVa
    Posts
    5,467
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Kind of like rebooting windows, but try restarting mysql?
    Sara

  5. #5
    SitePoint Member
    Join Date
    Jan 2006
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up

    Thanks for the advice, but I found the answer on a tutorial for setting up users. I thought

    grant all on database.*
    to user@"%"
    identified by 'password';

    would set the privileges for localhost as "%" is said to represent any server. Turns out it doesn't represent localhost.

    Once I declared all the privileges I wanted for localhost I was able to use my new user.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •