htpasswd to mysql table

Can't seem to find this anywhere on the net so time to ask.

How can one take the contents of an htpasswd file and convert it to username/password in a mysql table.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Do you want to use that for authentication against MySQL, or just store file data in a table with two columns?
projectsAuthor Commented:
Right, just the two columns, username and password, so I can use apache/mysql auth instead of htpasswd file.
Protecting & Securing Your Critical Data

Considering 93 percent of companies file for bankruptcy within 12 months of a disaster that blocked access to their data for 10 days or more, planning for the worst is just smart business. Learn how Acronis Backup integrates security at every stage

projectsAuthor Commented:
Sorry, I've no idea what the link information means. I know it's to load a file but can you give me an example instead of a link. I searched and tried various things but I'm not a programmer so need more detail.

projectsAuthor Commented:
My htpasswd file is pretty small so I could replicate it by hand but I can't find any info on how to create encrypted username/passwords to be stored in mysql. Seems I would need a bash or php script or something to do this.

What I have found so far simply create non encrypted accounts into the mysql table using normal mysql commands. I'd like those to be encrypted in the db along with some plain text ones.
Do you have httpasswd with plain passwords like netware?
projectsAuthor Commented:
Netware? I've not heard that term since the 80's :).

Anyhow, I've re-created all of my users/passwords in a mysql table so now I just need to figure out the stupid changes with centos7 to get this working since mod auth mysql is now deprecated.
To encrypt salted passwords
openssl passwd -help

-1 -5 -6 are nearly universally supported.
projectsAuthor Commented:
Basically, this question is already answered at this point. The question was how to import htpasswd file into a mysql table so I could start using apache mysql auth.

The answer was that I had to re-create all of the accounts manually since I could not find a way of converting/importing the existing htpasswd file into the new mysql table.

My next problem (question?) however will be that of modifying apache to use the new table instead of the .htpasswd file. So far, that seems to be a confusing topic to many because some mods have been deprecated, etc.

awk -F: '{print $1":" `echo $2 | openssl passwd -1`}' <oldfile > saltfile


Mysql> LOAD DATA FIELDS TERMINATED BY ':' user,password

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
I think I left unnecessary space before echo - check the file, there should be no space after colon.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.