I am writing a MySQL script defining users and roles, but I don't want to upload the password to the repository. So I was guessing if I can replace those passwords with yaml variables.
USE test;
DROP USER IF EXISTS 'admin'@'127.0.0.1';
CREATE USER IF NOT EXISTS 'admin'@'127.0.0.1' IDENTIFIED BY 'password';
Changing the file to
USE test;
DROP USER IF EXISTS 'admin'@'{admin.host}';
CREATE USER IF NOT EXISTS 'admin'@'{admin.host}' IDENTIFIED BY '{admin.password}';
DROP USER IF EXISTS 'client'@'{client.host}';
CREATE USER IF NOT EXISTS 'client'@'{client.host}' IDENTIFIED BY '{client.password}';
admin:
host: 127.0.0.1
password: password
client:
host: 0.0.0.0
password: 123456
But I do not know how to implement this in MySQL. I was thinking in making a bash script to manually replace the variables, but not all of the team uses linux, so I would like to know if there is a MySQL way to do this.
IDENTIFIED AS 'auth_string'
where that is a s password hash. ref.