错误如下,很怪异,首先查看mysql的sock文件位置,是在tmp下面。

[root@localhost ~]# ps -ef | grep mysql
root     30451 26264  0 17:14 pts/2    00:00:00 grep mysql
root     32149     1  0 Aug13 ?        00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/var --pid-file=/usr/local/mysql/var/localhost.localdomain.pid
mysql    32279 32149  0 Aug13 ?        00:00:28 /usr/local/mysql/libexec/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/var --user=mysql --log-error=/usr/local/mysql/var/localhost.localdomain.err --pid-file=/usr/local/mysql/var/localhost.localdomain.pid --socket=/tmp/mysql.sock --port=3306

然后修改/etc/authlib/authmysqlrc

[root@localhost ~]# vim /etc/authlib/authmysqlrc
 
MYSQL_SERVER            localhost
MYSQL_USERNAME          extmail
MYSQL_PASSWORD          extmail
MYSQL_SOCKET            /tmp/mysql.sock
MYSQL_PORT              3306
MYSQL_OPT               0
MYSQL_DATABASE          extmail
MYSQL_USER_TABLE        mailbox
MYSQL_CRYPT_PWFIELD     password
MYSQL_UID_FIELD         uidnumber
MYSQL_GID_FIELD         gidnumber
MYSQL_LOGIN_FIELD       username
MYSQL_HOME_FIELD        homedir
MYSQL_NAME_FIELD        name
MYSQL_MAILDIR_FIELD     maildir
MYSQL_QUOTA_FIELD       quota
MYSQL_SELECT_CLAUSE     SELECT username,password,"",uidnumber,gidnumber,\
                        CONCAT('/home/domains/',homedir),               \
                        CONCAT('/home/domains/',maildir),               \
                        quota,                                          \
                        name                                            \
                        FROM mailbox                                    \
                        WHERE username = '$(local_part)@$(domain)'

重启服务。还是报错。我明明修改了是tmp下面呀。他还是读不到。报错如下,解决方法贴在最后面。

post/etc/authlib/authmysqlrcfix/cleanup[26262]: warning: connect to mysql server localhost: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

既然你老是去读/var/lib/mysql/mysql.sock,那么给你弄个软连接吧,让你读得到,行吧。我还是搞不懂哪里配置错了- -
解决方法如下:创建目录。做个软链接
mkdir /var/lib/mysql 
ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock