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'
link|improve this question

71% accept rate
feedback

1 Answer

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.

link|improve this answer
Thanks! Exactly that! – matt74tm Oct 17 '10 at 18:12
feedback

Your Answer

 
or
required, but never shown

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