Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Apr 2007
    Location
    India
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    using password in mysql

    I used the below query for setting password.

    Code:
    SET PASSWORD FOR ''@'localhost' = PASSWORD('newpwd');
    After using it I cannot enter into mysql. When I entered mysql.exe, it is not going inside. But when I use mysql.exe -u root, its going inside.

    I don't know where the password was actually set. Let me have any solutions

    Rgds
    GemGuy

  • #2
    Regular Coder
    Join Date
    Mar 2007
    Posts
    505
    Thanks
    1
    Thanked 19 Times in 19 Posts
    You set the password for the '' account, or anonymous account.

    Have you tried mysql -p password ?

    You don't need to set the user if you are using the anonymous account.

    Secondly, why do you have an anonymous account? Even web accounts need to have usernames and passwords in them to ensure that your data is safe. Even by giving the ANON account a password, you are opening yourself to attack.

  • #3
    New Coder
    Join Date
    Apr 2007
    Location
    India
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    mysql password

    hi,

    I had also tried those things -p and -u root to connect database.. But all went in vein.. Please come up with some other solutions.

    GemGuy

  • #4
    Regular Coder
    Join Date
    Mar 2007
    Posts
    505
    Thanks
    1
    Thanked 19 Times in 19 Posts
    By your post, you are on some Windows variant (2000/XP), and you have not set your root password (which is why 'mysql -u root' can get you in).

    FYI -- you need to change the root password. This is a security hole that needs to be plugged.

    I would also try :
    Code:
    mysql -u  -p 
    
    OR
    
    mysql -u '' -p
    although I am not sure that will work.

    Since you can get in with the root user, I would delete the anonymous account and recreate one for yourself.

    mysql -u root

    use mysql;

    DELETE FROM user WHERE User = '';

    GRANT ALL PRIVILEGES ON *.* TO 'username'@'host' IDENTIFIED BY 'password' WITH GRANT OPTION;

    Replace username with the username that you want to use.
    Replace host with the computer that you want to connect from. Usually this is localhost.

    Replace password with the password that you want to use.

    Make sure that you include the single quotes in your statement!

    HTH!
    To say my fate is not tied to your fate is like saying, 'Your end of the boat is sinking.' -- Hugh Downs
    Please, if you found my post helpful, pay it forward. Go and help someone else today.

  • #5
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,633
    Thanks
    4
    Thanked 148 Times in 139 Posts
    Quote Originally Posted by gemguy View Post
    I used the below query for setting password.

    Code:
    SET PASSWORD FOR ''@'localhost' = PASSWORD('newpwd');
    After using it I cannot enter into mysql. When I entered mysql.exe, it is not going inside. But when I use mysql.exe -u root, its going inside.

    I don't know where the password was actually set. Let me have any solutions

    Rgds
    GemGuy
    after setting your password in this manner did you use

    FLUSH PRIVILEGES

    because if you did not, then that password did not take effect.

  • #6
    Regular Coder
    Join Date
    Mar 2007
    Posts
    505
    Thanks
    1
    Thanked 19 Times in 19 Posts
    And that, my friends, is why Guelphdad is the moderator and I am just a contributor.

    I completely forgot that if you do not use the FLUSH PRIVILEGES command, your user changes will not be pushed back into memory.

    I didn't even think of it because I always use the GRANT STATEMENT.

    Thanks Guelph!
    To say my fate is not tied to your fate is like saying, 'Your end of the boat is sinking.' -- Hugh Downs
    Please, if you found my post helpful, pay it forward. Go and help someone else today.

  • #7
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,633
    Thanks
    4
    Thanked 148 Times in 139 Posts
    I mostly use grant, but when I know I want to change only one item for a user sometimes just update the table. Originally didn't use GRANT because it seemed more confusing.


  •  

    Posting Permissions

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