473,387 Members | 1,463 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to secure MySQL database with user rights

I want to know whether MySQL is secured? I want to know how to create user in MySQL and I don't want to share any of the table of one user to other. How would I do this?
Mar 18 '10 #1
5 3756
rythmic
29
MySQL is as secure as you make it. If you use good coding practises while accessing the data the security is fine.

In order to not share tables between users you can only assign each user their own database, but is this really what you mean? do you mean a user to edit the tables or a user of a website using the database?

Those concepts are very different.

I can help you better if you would describe what you want it for.
Mar 18 '10 #2
Ok Rythmic. Right now i'm developing a product which is stand alone. I'm using Visual Studio with C# as front end and MySQL as database. I'm creating a new user from C# and creating database and tables. But if i login to MySQL as administrator with command prompt, i'm able to see all the databases and tables which i've created. How to hide that? May be in my code the user creation has some defect.
Mar 18 '10 #3
rythmic
29
If you login as mysql administrator you will see all the databases you have administrative rights to. Check out the GRANT command in mysql.

You can GRANT users different rights to different databases. unfortunately not to different tables.

You should take a look here.
http://dev.mysql.com/doc/refman/5.1/en/grant.html
Mar 20 '10 #4
@rythmic
Ok Rythmic. Thanks a lot. Right now i'm bit busy. So will check this later and will ask you if i get any more doubts.. :)
Please help me out in learning those things...
Apr 9 '10 #5
rythmic
29
I'll be around :)

I was reading through our conversation and started thinking about concepts. Just to make sure we are discussing this from the same point of view, here is an intro to db user concepts and application users.

If you create a User in C# as a class, this has nothing to do with the user accessing the mysql database

A good practise is to have two kinds of users for the database. one with read rights and one with read/write rights. This way you can use the read user when doing searches in the system and that way protecting the system from malicious code in form inputs. And in the same way, only use the write user when you want to add, update or remove data in the database.

To clarify: In your database you only need two separate users no matter how many users you have in your c# application.

To limit users of your C# application to see only data in the database that is meant for them you need to have some way to identify each user. Very common is a user ID which is basically a field in your class with type int... something like this:

Expand|Select|Wrap|Line Numbers
  1. // a class in some namespace
  2. public class User {
  3.  
  4. int id;
  5. string username;
  6. string password; 
  7.  
  8. //additional info
  9.  
  10. public User(int id) {
  11.  
  12.  // fetch data from the database about this user here
  13. }
  14.  
For the database to know which data belongs to which user you need to add a field in each table that says "This info is about this user".
You do that by adding a column in your table. Name it something appropriate like user_id and just like the field id in your c# class, it should be an int.

Say you have a table about dogs:,

Expand|Select|Wrap|Line Numbers
  1. ------------------------------
  2. | Table : dogs          
  3. ------------------------------
  4. | name                    
  5. | breed                    
  6. | height                   
  7. | weight                  
  8. | owner                     // this column is your user_id from the c# app
  9. -------------------------------
  10.  
So, now each dog has an owner which you can identify through the user id which in this table is known as owner

You should also store your application users in your database. for instance like this.

Expand|Select|Wrap|Line Numbers
  1. ------------------------------
  2. | Table : users         
  3. ------------------------------
  4. | user_id                 
  5. | username             
  6. | password              
  7. -------------------------------
  8.  
Now you can see which user owns which dog and do combined searches on them through SQL.
May 4 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Mark1 | last post by:
Hi, as I did not find a group for MySQL I try my luck here. Plz tell me, if there is a better cathegory for MySQL... I´ve got several MySQL Databases running on a Linux 8.1 Server. User...
6
by: Sarah Tanembaum | last post by:
I was wondering if it is possible to create a secure database system using RDBMS(MySQL, Oracle, SQL*Server, PostgreSQL etc) and web scripting/programming language(Perl, PHP, Ruby, Java, ASP, etc)...
0
by: Ola Ogunneye | last post by:
--=_7B255FAE.1F7E0C30 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Hello all, Let me start out by saying that I am still a newbie. I just freshly installed...
0
by: Lefevre, Steven | last post by:
Hey folks - Thanks to everyone who gave input to my concerns. Of course, we don't intend to have the mysql port open to the world. We will have Apache/PHP connect on a unix socket, or to another...
8
by: peter | last post by:
I have taken over the website duties at work. I am still learning PHP and MySQL. I want to have a form where the user enters some finacial info and it is stored in a database. It, obviously,...
6
by: Ook | last post by:
Has anyone sucessfully connected a C# asp form to a MySQL database? If so, would you care to share how you did it?
5
by: Joe | last post by:
I have an application which runs in a non-secure environment. I also have an application that runs in a secure environment (both on the same machine). Is there any way to share the session data for...
20
by: Gef.Mongoose | last post by:
I MD5 encrypt passwords in a user table of my database. I have a global application object (initiated in global.aspx) which contains a few static members (for counting users online etc). because...
14
by: knal | last post by:
Hi there, I'm looking for a secure login script for a sort-of-community site... (PHP, MySQL, sessions, or maybe something else ... ) I know there are a lot of scripts out there, but none of them...
15
by: harvey | last post by:
How do I make PHP create a database for mysql please? I can see how to make tables and I have read all the documents I can find but I don't understand how to make the database itself. All...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.