• 0

Should I create a unique MySQL user per logged in person?


Question

Yo Neowin!

I want to know what do you suggest in terms of security, and speed, whether is recommended or not to create an individual user for each person that logs in to my site.

I mean. I usually verify a username on a table, and assign unique tables to each of my users with a General MySQL user account with limited privileges. But since I've been reading a little bit more about MySQL (I only know the basics), I've seen that to improve security I could assign certain limits on MySQL users and only allow access to certain tables.

So, what can you suggest me in terms of MySQL users?

Thanks :p

14 answers to this question

Recommended Posts

  • 0

What do you mean unique mysql user per logged in user, what type of site is this?

I mean, to create a MySQL user. The default user on a MySQL server is root. I would like to know if it would improve security having a separate user like "John" which would only access Joh_products and John_clients table and will have limited privileges like SELECT, DROP, UPDATE, INSERT commands.

This site, is on development right now, so everything can be modified. It's a receipt management website, which each of the users will have their own clients stats, number of purchases, receipts, etc.

  • 0

I mean, to create a MySQL user. The default user on a MySQL server is root. I would like to know if it would improve security having a separate user like "John" which would only access Joh_products and John_clients table and will have limited privileges like SELECT, DROP, UPDATE, INSERT commands.

This site, is on development right now, so everything can be modified. It's a receipt management website, which each of the users will have their own clients stats, number of purchases, receipts, etc.

I truly would not recommend that at all.

  • 0

NEVER use the root account AT ALL once you've configured the MySQL server, make another account and grant it root-like permissions and ONLY use the root account as a last resort if something breaks to restore everything.

Yes use different accounts for different sites, one account for all clients on one site should be fine i.e. one account for this receipt tracking site, another account for a control panel site, etc.

  • 0

You should only really need one master user for the mysql database itself. Then use web based forms (in PHP for example) to allow the people to add/delete/update their data. They don't need to have direct access to the database tables to do this. I don't really see the point of having totally distinct tables for each user either. Seems like a lot of duplication and you'll end up with a massive amount of tables.

  • 0

Thanks to all of the above. Now I have a clear mind.

NEVER use the root account AT ALL once you've configured the MySQL server, make another account and grant it root-like permissions and ONLY use the root account as a last resort if something breaks to restore everything.

Yes use different accounts for different sites, one account for all clients on one site should be fine i.e. one account for this receipt tracking site, another account for a control panel site, etc.

I shall take this recommendation then :)

I don't really see the point of having totally distinct tables for each user either. Seems like a lot of duplication and you'll end up with a massive amount of tables.

:/ There was no other way my logic could function.

I Googled a bit and found that there wasn't any problem having multiple tables. The thing is that it allows flexibility. I didn't see a good way on putting the client info, the receipt #, the quantity, price of the product purchased (because it has a variable price), the current product id, the tax, and whether it was paid, delivered or not. So I could fetch it in a productive way later on....

Anyways, I'm open to suggestions :D

  • 0

I Googled a bit and found that there wasn't any problem having multiple tables. The thing is that it allows flexibility. I didn't see a good way on putting the client info, the receipt #, the quantity, price of the product purchased (because it has a variable price), the current product id, the tax, and whether it was paid, delivered or not. So I could fetch it in a productive way later on....

Multiple tables are fine, in fact you should be using multiple tables, but there's a much better and organized way of using them. You should be using different tables for storing types of data. If I have Users, Customers, and Receipts; I would create a separate table for each one of them. Then I would create two additional tables used for associations, one for Users->Receipts, and one for Customers->Receipts. These associative tables would only store the unique id's for the rows in the other tables.

Not sure if I explained clear enough or not, also not sure if it's quite the same idea as your system. Either way its best to have different table's for different types of data, since there's no sense in storing the same data multiple times.

  • 0

Certainly use multiple tables, but not for each user. Say you have 10 users and each user has a separate table, if you want to see all the data from all the users you have to search through 10 tables, vs. just the main table for the type of data you want.

So instead of userA_orders, userB_orders, etc. you just have a single orders table, and store what user created the order in the record you insert into the table.

  • 0

if i've read this right. you should create a function user. one user that can insert, update, or delete records, but not modify the database structure. use that user for any transaction, and the root as a last resort.

  • 0

Multiple tables are fine, in fact you should be using multiple tables, but there's a much better and organized way of using them. You should be using different tables for storing types of data. If I have Users, Customers, and Receipts; I would create a separate table for each one of them. Then I would create two additional tables used for associations, one for Users->Receipts, and one for Customers->Receipts. These associative tables would only store the unique id's for the rows in the other tables.

Not sure if I explained clear enough or not, also not sure if it's quite the same idea as your system. Either way its best to have different table's for different types of data, since there's no sense in storing the same data multiple times.

Certainly use multiple tables, but not for each user. Say you have 10 users and each user has a separate table, if you want to see all the data from all the users you have to search through 10 tables, vs. just the main table for the type of data you want.

So instead of userA_orders, userB_orders, etc. you just have a single orders table, and store what user created the order in the record you insert into the table.

Now I get it! Yup. Indeed. I know my logic was failing somewhere.

I just need to create a separate column with the current logged in user, and bang it with a WHERE clause to identify the user (*poker face*)

Aaaargh.

Going to work on it right now

Thank you people :D

This topic is now closed to further replies.
  • Posts

    • Google reportedly limited Meta's Gemini access over limited AI compute by Karthik Mudaliar Google is reportedly limiting Meta's use of its Gemini AI models after Meta tried buying more computing capacity than even Google could supply. According to the Financial Times, Google told Meta in March that it could not provide the full Gemini capacity that Meta had requested. This shortfall even disrupted and delayed some of Meta's internal projects. Due to this, Meta even told its employees internally to use AI tokens more efficiently. Meta wasn't the only one to get hit by this sudden refusal by Google; even other customers were affected. But Meta was hit harder because of its unusually high demand for Google's models. The move from Google makes it evident that companies all over are in limited supply of both infrastructure and compute. Alphabet said in April that Google Cloud revenue grew 63% year-over-year to $20 billion in the first quarter, helped by enterprise AI infrastructure and AI solutions. In pursuit of more compute, Meta had earlier signed a multi-billion-dollar AWS agreement as well as a large AMD GPU deal for AI data centers. But the crunch would be short-lived as both Meta and Google have also ramped up infrastructure investments heavily. Meta said in November that it was committing more than $600 billion in the U.S. by 2028 for AI technology, infrastructure, and workforce expansion. In the first quarter of this year, Meta also raised its expected capital expenditure for 2026 to a range of $125 billion to $145 billion, citing higher component pricing and additional data center costs for future capacity. However, this doesn't make the company immune to the current dependence on outside suppliers. Meta has also spent many years promoting Llama as an open-weight alternative to closed models from Google, OpenAI, and Anthropic. But if the reported reliance on Google's Gemini models is severe enough for internal work to get impacted, then it looks like even frontier labs and Big Tech aren't fully self-sufficient. Source: Financial Times
    • I like to reminisce about the good old days, way back in autumn 2025 when building a gaming machine was fun and the drives were about $150 when you caught a deal. Yes duh, back in the day we had it gone. Then baby Skynet came along, hiding in AI datacenters demanding more processing power until it reached singularity. End of a not totally fictional story.
    • My experience in the past with older Windows 11 builds was not great on unsupported machines but I recently used Rufus to put the latest build on a older 5th Gen Core Thinkpad T that we upgraded with a SATA SSD and 8GB of RAM four years ago when hardware was reasonable and it seemed pretty fast and solid. Customer is very happy with the performance and will probably get four more years out of that venerable laptop that he loves so much. Another customer just retired his Dell Studio laptop from 2009 running Windows 10. It got an SSD over 10 years ago and did everything he needed it to for 17 years but he also retired last year and is happy doing everything on his iPad now.
    • Apple's newest AirTag 2 gets first big discount by Taras Buria In late January 2026, Apple introduced its second-generation AirTag trackers, bringing a refresh to the old model that has been on the market for half a decade. Now, you can get these new trackers at an all-time low price, thanks to the first big discount that brought the price down by 17% on Amazon. While the second-generation AirTag looks identical to its predecessor, it packs meaningful upgrades inside. The second-gen ultrawideband chip works 50% farther than the original AirTag, allowing you to detect lost items in a wider range. In addition, the second-generation AirTag features an upgraded Bluetooth chip for extended range and a significantly louder speaker (up to 50%) so that you can hear it better when locating a lost item. Note that the second-gen AirTag only works with iPhones and iPads that run iOS/iPadOS 26 and newer, so you need a compatible device to use the tracker. Like the original AirTag, the AirTag 2 is available in two packs: one and four pieces. Both are now available at a notable discount on Amazon, and you can purchase them using the links below. Apple AirTag 2 tracker - $24 | 17% off on Amazon Apple AirTag 2 tracker (four-pack) - $89 | 10% off on Amazon Good to know This Amazon deal is U.S.- specific and not available in other regions unless specified. We only use first-party seller links (at the time of article publishing); ensure that you purchase from a first-party seller link only. Check out Today's Deals on Amazon | or our recent tech deals. Become a Prime member (for Students or SNAP) via Neowin Get Prime Access - Prime for half price (for qualifying Medicaid, EBT, SNAP) Subscribe to Prime Video, Audible Plus, Music Unlimited or Kindle Unlimited via Neowin As an Amazon Associate, we earn from qualifying purchases.
    • I've been on Deezer for over a decade, but glad that Tidal joined them in fighting AI slop. Can't stand such takes as Spotify's: "Spotify's CEO recently pushed back against listeners who call AI music "slop," urging people to stop using the term and instead embrace the creative potential of AI music."
  • Recent Achievements

    • Reacting Well
      NovaEdgeX earned a badge
      Reacting Well
    • Week One Done
      NovaEdgeX earned a badge
      Week One Done
    • One Year In
      BA the Curmudgeon earned a badge
      One Year In
    • Conversation Starter
      rosiecharles earned a badge
      Conversation Starter
    • First Post
      KMilenkoski1202 earned a badge
      First Post
  • Popular Contributors

    1. 1
      +primortal
      536
    2. 2
      +Edouard
      266
    3. 3
      PsYcHoKiLLa
      150
    4. 4
      Steven P.
      98
    5. 5
      macoman
      66
  • Tell a friend

    Love Neowin? Tell a friend!