Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

When I create a new Mysql user, it is impossible to login using this user and password. Only if I crate a user without a password I can login.

For example:

mysql -u root -phererootpass
 grant all privileges on mydb.* to testuser@'%' identified by '' with grant option;
 grant all privileges on mydb.* to testuser2@'%' identified by 'mypass' with grant option;
 FLUSH PRIVILEGES;
 exit;

mysql -u testuser  #<<< work fine

mysql -u testuser2 -pmypass  #<<< fail to login
ERROR 1045 (28000): Access denied for user 'testuser2'@'localhost' (using password: YES)
</code>

I'm using Mysql 5.0 on Red Hat v5

Please advice Mostar

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

What you've set up only allows you to connect from all other servers other than localhost. You need to run this as well

grant all privileges on mydb.* to testuser2@'localhost' identified by 'mypass' with grant option;

And then remember to flush your privs.

share|improve this answer
    
@mostar - you may want to visit stackoverflow.com. You'll find that this topic is covered more there. –  Patrick R Jan 6 '11 at 17:20
    
Thanks, that was the problem. –  mostar Jan 7 '11 at 7:40
add comment

Try setting the environment variable MYSQL_PWD?

export MYSQL_PWD='mypass'
mysql -u testuser2 -p

In my experience passing the password as a part of the CLI is a bad idea. (it will show up in your process list for any user to see with 'top')

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.