Mysql – convert plain text passwords to sha512-crypt in dovecot + postfix’s thesql mailbox table

dovecotMySQLpostfixroundcubeubuntu-15.10

I have an old postfix + dovecot + Roundcube mailserver (mail.domain.Tld). Server clock is loosing time and adjusting it causes dovecot to kill itself, we cannot install more memory, bigger hard-drives, etc.

I have built a new server box (mail2.domain.Tld) With Postfix + dovecot + Roundcube. This server is functioning, with a client's new domain, and my personal domain. it's password system is SHA512-CRYPT.

I have imported the users from the old server over to the new server. I have created a new column "plain_pass" for the plain passwords.
I have been following this "tutorial" without much luck – http://wiki2.dovecot.org/HowTo/ConvertPasswordSchemes#CA-26af2b83a43b8100522c57565773f605c21f2f27_1

Best Answer

From the dovecot support group, Particulary - Gedalya:

Run this mysql query:

UPDATE mailbox set password = ENCRYPT(plain_pass, CONCAT('$6$',sha(RAND()))) WHERE password IS NULL OR password='';