dump two mysql fields to create .htpasswd file
Posted on 2014-11-17
I need to dump two fields ('username' and 'password') from a mysql table into a file which a bash script could then turn into an .htpasswd file. In other words, I need a constantly updated .htpasswd file based on the data in the table.
Or, a script which could read the database directly while creating the .htpasswd file.
Using the -b option, I can create the .htpasswd file like this;
htpasswd -b .htpasswd $USER $PASSCODE
If the script read the table directly though, would it not mean many reads instead of just one to grab all of the names/passwords? This needs to be done several times daily so I want to do this with as little impact as possible on mysql.
Looking for the Linux Bash code which would accomplish this.