Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should a users table be in a different database than website content?

Apologies if this has been asked before, but I did some searching and wasn't able to find an answer to my question.

I have my website content stored in a MySQL database (let's call it content) and I need to write a simple login system for my website. So, I need to create some sort of users table that holds usernames, passwords, permissions, etc., and what I'm wondering is whether I should just make this a new table in my content database, or if it would be more secure to have it stored in a new database? The downside to having it in a second database is that I will have to use two database connections instead of one.

Maybe this is a silly question, but I appreciate your input!

like image 721
Nate Avatar asked Mar 25 '26 16:03

Nate


1 Answers

You don't need to use a differnt db. That's more reserved for when you've got data that has completely DIFFERENT purposes, e.g. company A has a db and company B has a db.

Note that simply having two different databases does NOT require two different database connections to access. As long as the user ID you're logging into the DB with has proper access rights, you can do:

SELECT onedatabase.table.field, someotherdatabase.table.field
...
like image 187
Marc B Avatar answered Mar 27 '26 04:03

Marc B



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!