Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7979105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:41:04+00:00 2026-06-04T09:41:04+00:00

How should ‘sensitive’ data be stored in MySQL Database? 1) Should I focus more

  • 0

How should ‘sensitive’ data be stored in MySQL Database?

1) Should I focus more on the security of the MySQL database and store the data as plain text?

  • I found a step by step tutorial on how to make a MySQL database more secure:
  • http://www.symantec.com/connect/articles/securing-mysql-step-step

2) Should I encrypt the data?

  • If yes, then how should the encryption be done?
    1. Using MySQL aes_encrypt/aes_decrypt?
    2. Using PHP AES functions/algorithm for encrypting/decrypting data?
  • How should the data be stored in MySQL?
    1. BLOB
    2. BINARY
    3. VARBINARY

In my case the ‘sensitive’ data are payments done by individuals.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T09:41:05+00:00Added an answer on June 4, 2026 at 9:41 am

    It’s a mixture of both. Two existing answers (at the time I wrote this https://stackoverflow.com/a/10718397/1015483 and https://stackoverflow.com/a/10718459/1015483) are valid – you need to look at about 5 methods of possible attack that I can think of

    • They get access to your DB server; so yes, secure that baby as much as is reasonable (Matt’s answer)
    • Stand alone data hijacking (someone gets to your database data somehow else, could be a backup, could be they guess a password, could be MITM if you transfer data from one place to another). For this, you do encypt your data. You also may do a CSV dump for some reason and e-mail to someone. Whoops. But it happens. So encrypt (vlzvt’s answer)

    But three elements not mentioned:

    • They could gain access to your web server (if different from your DB server). If they have access to the webserver, all bets are off as they have your password, encyption keys the lot. So you need to make that even more secure than the DB server. (Matt might have meant that above – but just make it clear)
    • Similar to above, but not to be forgotten, is if someone gets access to phpMyAdmin or your management consule. Don’t use plain text auth or config stored passwords for access.
    • Finally there’s your application itself (and the hardest to lock down). You need to prevent against SQL injections that may reveal data. Encrypting the data would stop minimise problems if someone did gain access through an untrapped query – so for this, encryption is the solution.

    For part 2 of your question:

    Using MySQL encrypt/decrypt functions will stop someone who has access to the raw data, but not MITM or SQL injection or even CSV dumps taken for transport.

    So, IMO (and it’s only my opinion and the way I’ve done it) is to encrypt with PHP and sned the encrypted data over the wire, as that stops all methods of trapping the data, and a CSV dump will be “scrambled”.

    If you do that, you may as well use the varbinary / blob types as it stops you accidentally trying to read/edit in phpMyAdmin. Plus potentially saves a few bytes nominally (although this depends on indexes and other stuff – so that alone is not a winning argument).


    And now the down side: searching and sorting. Anything you index or search on, if encrypted, will only match the entire, exact, case sensitive string padded to the correct length (normally a search will be case insensitive, and you can do part searches with LIKE). And if you want to ORDER BY then you need the original strings. So bear than in mind when designing the structure.

    Hope that helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Should I store all datetime's in MySQL database in UTC? (Using UTC_TIMESTAMP()) How can
Should a value always be stored in a database using a specific unit (e.g.
Should application expect the unexpected when fetching data from database? Lets say that we
should a non-database data class I need be created as a Rails 3 model,
should be simple right? but have not found any anwsers :
Should I have area code stored in a separate field in my DB? It's
Should I store it in a single timestamp/datetime field or separate date and time
Should I pair every data() call with a later removeData() call? My assumptions: jQuery's
Should I prefer binary serialization over ascii / text serialization if performance is an
Should libraries that the application relies on be stored in source control? One part

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.