I used to be able to create a MySQL-compatible password by running my password through sha1 twice, but it appears this doesn't work in MySQL 8.
MySQL seems to use these password plugins now. The syntax is thus (in JS):
const createUserSql = `CREATE USER ${db.escapeValue(agency.login)} IDENTIFIED WITH mysql_native_password BY ${db.escapeValue(passwordHash)};`;
I want to create passwords in Node.js that will work with MySQL. I know I can just use plain-text passwords and let MySQL hash them, but I'm printing this SQL to a terminal and I don't want the passwords to be visible, so I want to pre-hash them.
What algorithm will work with MySQL 8? I'm willing to use any of the built-in password plugins.
sha256_password sounds nice, but I don't think it's a straight sha256 hash, sounds like it has a salt built in, so I'm not sure how to create one in Node.js.
The MySQL PASSWORD()
function is gone too. I didn't really want to do a SELECT PASSWORD(:plainTextPass)
to hash my passwords, but now that isn't even an option.