Connect failed to database

Dan LaSota dlasota at alaska.edu
Mon Mar 2 18:30:13 UTC 2015


>> 
>> Just some quick ideas
>> * check if the mysql socket file has rw permissions for the dovecot user

# ls -l /var/lib/mysql/mysql.sock
srwxrwxrwx. 1 mysql mysql 0 Mar  1 19:33 /var/lib/mysql/mysql.sock
>> 
>> * Try to run the mysql query as user dovecot (su dovecot)

The dovecot user I set up is a non-interactive user
/sbin/nologin

I studied different setup guides, and all of them suggested setting up dovecot with a non-interactive shell.
However the mysql client is world executable:
# ls -l /bin/mysql
-rwxr-xr-x. 1 root root 3533008 Feb  5 05:47 /bin/mysql

>> * Try to set the local ip instead of localhost (mysql makes a difference in the ACL checks if you come from localhost)

I have tried with 
connect = host=localhost dbname=servermail user='usermail' password='gjwslegosoghjshloehg$_jsdgh'
and
connect = host=127.0.0.1 dbname=servermail user='usermail' password='gjwslegosoghjshloehg$_jsdgh'

still doesn't work:
Mar  2 04:58:48 mail dovecot: auth-worker(5745): Error: mysql(127.0.0.1): Connect failed to database (servermail): Access denied for user 'usermail'@'localhost' (using password: YES) - waiting for 1 seconds before retry


> 
> 
> * Did mysql logged something useful?

I have turned on general-log in MySQL (actually mariadb):
A few things to note: connection 221 is me manually logging into the server from the command line.
The other numbers are dovecot. I'm using the same credentials as the dovecot config files.
(not sure if this is useful or not)

					221 Connect	mailuser at localhost as anonymous on 
					221 Query	select @@version_comment limit 1
150302	9:18:33		221 Query	show databases
150302	9:18:38		221 Query	SELECT DATABASE()
					221 Init DB	servermail
					221 Query	show databases
					221 Query	show tables
					221 Field List	virtual_aliases 
					221 Field List	virtual_domains 
					221 Field List	virtual_users 
150302	9:18:43		221 Query	show tables
150302	9:18:50		222 Connect	usermail at localhost as anonymous on servermail
					222 Connect	Access denied for user 'usermail'@'localhost' (using password: YES)
					223 Connect	usermail at localhost as anonymous on servermail
					223 Connect	Access denied for user 'usermail'@'localhost' (using password: YES)
150302  9:18:56		221 Query	select * from virtual_users
150302  9:19:19		224 Connect	usermail at localhost as anonymous on servermail
					224 Connect	Access denied for user 'usermail'@'localhost' (using password: YES)
					213 Quit	
					214 Quit	
					215 Quit	
150302  9:19:20		225 Connect	usermail at localhost as anonymous on servermail
					225 Connect	Access denied for user 'usermail'@'localhost' (using password: YES)
150302  9:19:24		221 Quit	
150302  9:19:25		226 Connect	usermail at localhost as anonymous on servermail
					226 Connect	Access denied for user 'usermail'@'localhost' (using password: YES)
150302  9:19:50		227 Connect	usermail at localhost as anonymous on servermail
					227 Connect	Access denied for user 'usermail'@'localhost' (using password: YES)





Dan LaSota
Instructional Designer, UAF eLearning
(907) 451-4067
dan.lasota at alaska.edu
http://elearning.uaf.edu



More information about the dovecot mailing list