Friday, January 28, 2011

Unable to connect to database as created user - ERROR 1044 (42000): Access denied for user

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'
  • 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.

    matt_tm : Thanks! Exactly that!
    From Ben

0 comments:

Post a Comment