Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a redhat linux server with root password A

When setting up MySQL, I gave it a password B (not A)

I need to connect to 'mydatabase' as user 'myusername'

Listing users shows:

mysql> select user();
| user()         |
| root@localhost |
1 row in set (0.00 sec)

mysql> select * from mysql.user;
| localhost | root            | qqqqqqqqqqqqqqq1 |
| localhost | myusername      | qqqqqqqqqqqqqqq2 |

But I cant seem to connect to it from the command line:

# mysql --database=mydatabase --user=myusername --host=localhost --password=qqqqqqqqqqqqqqq2
ERROR 1044 (42000): Access denied for user 'myusername'@'localhost' to database 'mydatabase'
share|improve this question

1 Answer 1

up vote 0 down vote accepted

Have you granted myusername permissions on mydatabase?

The command you would do that with is GRANT ALL ON mydatabase.* TO 'myusername'@'localhost'; (log into MySQL as root when doing this).

Then flush the privileges with FLUSH PRIVILEGES; so it takes effect.

share|improve this answer
Thanks! Exactly that! – siliconpi Oct 17 '10 at 18:12

Your Answer


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.