To create a password using the SHA512-CRYPT schema:

SELECT ENCRYPT("password", CONCAT('$6$',sha(RAND())));

To create an user:

INSERT INTO users SET password=ENCRYPT("password", CONCAT('$6$',sha(RAND())));

To use with postfix or dovecot:

INSERT INTO users SET password=CONCAT('{SHA512-CRYPT}', ENCRYPT("password", CONCAT('$6$',sha(RAND()))));