3

I need to change a password of a postfix user account mailbox directly in a MySQL database; however I have no idea of the format used.

Here is the table:

SELECT username,password FROM mailbox LIMIT 1;
+------------------+------------------------------------+
| username         | password                           |
+------------------+------------------------------------+
| user@example.com | $1$60Dgu9vc$T7vaQfTKgxUpci0TTnsyO0 |
+------------------+------------------------------------+

What format is it? How to change it?

3

The $1$ at the beginning of the password field hints it is a MD5 hash.

To encrypt a password in a MD5 hash, you can use the openssl passwd command.

From man openssl:

passwd Generation of hashed passwords.

and from openssl passwd --help:

-1 MD5-based password algorithm
-stdin read passwords from stdin

So to generate the MD5 hash, a short bash example:

#/bin/bash
PASSWORD="test123"
MD5=`echo $PASSWORD | openssl passwd -1 -stdin`

Running it, you got as output the intended encrypted password:

$1$EaYOC8n4$04LSDBtt4A8GPVRUkzBXG/

So to change the password in the MySQL DB to 'test123', you do in the MySQL prompt:

USE postfix UPDATE mailbox SET password="$1$EaYOC8n4$04LSDBtt4A8GPVRUkzBXG/" WHERE username="user@example.com";

The change takes effect immediately, and the user will notice the change in the next mailbox access.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.