...

View Full Version : using password in mysql



gemguy
06-04-2007, 06:39 AM
I used the below query for setting password.


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

Daemonspyre
06-04-2007, 02:57 PM
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.

gemguy
06-07-2007, 08:51 AM
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:confused:

Daemonspyre
06-07-2007, 02:18 PM
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 :


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!

guelphdad
06-07-2007, 04:35 PM
I used the below query for setting password.


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.

Daemonspyre
06-08-2007, 02:06 PM
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!

guelphdad
06-08-2007, 09:12 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum