0

I've setup a mail server on an Ubuntu 14.04 server. I've installed Courier as the IMAP server and I've configured it so it can connect to MySQL and use its data as the user list and stuff.

I've already managed to configure Courier once to connect to MySQL on another machine. But right now I'm having problem doing it again on another machine.

Tailing the /var/log/mail.log file I can see that Courier can not connect to MySQL:

authdaemond: authmysql: mysql_select_db(MyDb) error: Access denied for user 'MyUser'@'192.168.1.10' to database 'MyDb'

It's in the case that I can connect to mysql server from the shell of the same machine using mysql client, with the same credential as given to Courier! How can this be possible?

Mehran
  • 519
  • 1
  • 5
  • 19
  • Does the password have any non-alphanumeric characters in it? – NickW Oct 29 '14 at 13:32
  • I've just set it to `123` and the result's the same. – Mehran Oct 29 '14 at 13:36
  • What do you get if you run `select user,host from mysql.user where user="MyUser";` ? – NickW Oct 29 '14 at 13:42
  • The list of associated users and hosts for "MyUser". I told you I can login to mysql server with the same credentials from the same machine. Which means the permission to access MyDb is granted to MyUser when he's accessing from 192.168.1.10. – Mehran Oct 29 '14 at 13:47
  • Did you actually try to access the database "MyDb" using the mysqlclient or did you only try to access the database server? – Thomas Stinner Oct 29 '14 at 13:50
  • I've executed the select query that courier was supposed to run with success. Do you think it can have something to do with the version of mysql server and/or mysql client? I'm using mysql server and client both of version 5.6. – Mehran Oct 29 '14 at 13:54
  • It's more likely your mysql-client is coming from localhost, not from 192.168.1.10, which is why I asked for a list of the users. Is there one that has the host 192.168.1.10? – NickW Oct 29 '14 at 13:56
  • The mysql server resides on another machine and both Courier and mysql-client need to address it as 192.168.1.45! – Mehran Oct 29 '14 at 13:58
  • The `@ip.add.re.ss`is the address that the CLIENT is coming FROM, not the address it is going to. What is the entry for the Courier machine in your mysql.users table? – NickW Oct 29 '14 at 14:28
  • My Courier resides at 192.168.1.10 and mysql server at 192.168.1.45. I have added a user to mysql server like MyUser@192.168.1.10 which I can use with mysql-client but not the Courier! The users table in mysql server holds usernames and passwords along with client IPs that they are accepted if the authentication request comes from them. Am I missing anything? – Mehran Oct 29 '14 at 14:38
  • No, though you may have a typo somewhere, or possibly the courier server is connecting to MySQL with an `@hostname` user string, you need to make sure that you either have a hostname entry, or that your DNS server maps 192.168.1.10 to whatever the server thinks its hostname is.. – NickW Oct 30 '14 at 15:29

1 Answers1

1

As @NickW guessed it was a typo in database name but I still think that the error message should have been more informative. It was telling me that the username and password were incorrect in the case that they were correct but no database with the specified name was available.

Once I cleared the password on server, the error changed to:

authdaemond: authmysql: mysql_select_db(MyDb1) error: Unknown database 'MyDb1'

And it was then that I realized I had a typo!

Mehran
  • 519
  • 1
  • 5
  • 19