Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-04-2007, 05:39 AM   PM User | #1
gemguy
New Coder

 
Join Date: Apr 2007
Location: India
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
gemguy has a little shameless behaviour in the past
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
gemguy is offline   Reply With Quote
Old 06-04-2007, 01:57 PM   PM User | #2
Daemonspyre
Regular Coder

 
Join Date: Mar 2007
Posts: 505
Thanks: 1
Thanked 19 Times in 19 Posts
Daemonspyre is on a distinguished road
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.
Daemonspyre is offline   Reply With Quote
Old 06-07-2007, 07:51 AM   PM User | #3
gemguy
New Coder

 
Join Date: Apr 2007
Location: India
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
gemguy has a little shameless behaviour in the past
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
gemguy is offline   Reply With Quote
Old 06-07-2007, 01:18 PM   PM User | #4
Daemonspyre
Regular Coder

 
Join Date: Mar 2007
Posts: 505
Thanks: 1
Thanked 19 Times in 19 Posts
Daemonspyre is on a distinguished road
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!
__________________
Quote:
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.
Daemonspyre is offline   Reply With Quote
Old 06-07-2007, 03:35 PM   PM User | #5
guelphdad
Super Moderator


 
guelphdad's Avatar
 
Join Date: Mar 2006
Location: St. Catharines, Ontario Canada
Posts: 2,629
Thanks: 4
Thanked 147 Times in 138 Posts
guelphdad will become famous soon enoughguelphdad will become famous soon enough
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.
guelphdad is offline   Reply With Quote
Old 06-08-2007, 01:06 PM   PM User | #6
Daemonspyre
Regular Coder

 
Join Date: Mar 2007
Posts: 505
Thanks: 1
Thanked 19 Times in 19 Posts
Daemonspyre is on a distinguished road
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!
__________________
Quote:
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.
Daemonspyre is offline   Reply With Quote
Old 06-08-2007, 08:12 PM   PM User | #7
guelphdad
Super Moderator


 
guelphdad's Avatar
 
Join Date: Mar 2006
Location: St. Catharines, Ontario Canada
Posts: 2,629
Thanks: 4
Thanked 147 Times in 138 Posts
guelphdad will become famous soon enoughguelphdad will become famous soon enough
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.
guelphdad is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:11 AM.


Advertisement
Log in to turn off these ads.