PDA

View Full Version : Access to one DB?


chabbs
08-28-2006, 10:19 AM
I'm working with a programmer that needs MYsql access but I don't want to give him access to the whole server. Is there a way to give him access to only one db? He needs to have all permissions for that db.

Thanks

nadzri
08-28-2006, 12:11 PM
Off the top of my head,
GRANT select, insert, update, create, alter, delete, drop ON <dbname>.*
TO <user>@localhost IDENTIFIED BY '<passwd>';
You can the same command and replace localhost with '%' if you want him to be able to access the server from anywhere.

chabbs
08-28-2006, 12:18 PM
Thanks for replying but this doesn't provide me much information. I need a few more details like where do I run this command?

airoid
08-28-2006, 03:44 PM
Are you talking about giving him access to your database *from* another server, or is he doing work on *your* server and you only want him to have access to one database?

chabbs
08-29-2006, 08:55 PM
Are you talking about giving him access to your database *from* another server, or is he doing work on *your* server and you only want him to have access to one database?

He is working on my server and I want him to be able to access only the database that he's working on.

airoid
08-29-2006, 09:08 PM
Why not create another account in WHM and have the database located in that account. That way you give him access to that account and he doesn't have access to yours.

chabbs
08-29-2006, 09:47 PM
The problem is that the database is live.

airoid
08-30-2006, 02:34 AM
You could do a database backup and then restore on the new account. Simply taking down the website for 5 minutes would do the trick.

sdjl
08-30-2006, 04:04 AM
You could just setup another MySQL user under cPanel (Presuming you're using cPanel of course!) and then assign that user access to the database they need to work on.
That way, they'll only have access to that database and can work on it whilst it's live.

David

chabbs
08-30-2006, 09:05 AM
You could just setup another MySQL user under cPanel (Presuming you're using cPanel of course!) and then assign that user access to the database they need to work on.
That way, they'll only have access to that database and can work on it whilst it's live.

David

How do you that?

The reason for my concern is that he would be able to back up and download my other database which is worth a lot. Ideally I'd like for him to only access that one database.

I've been considering setting up the database on another site in which he would have access to. That site resides on the same server as the other. Then through the config file in the program that he's working on point to that database. The database would reside permanently on the other site.

Do you think this would be good solution?

nadzri
08-30-2006, 11:10 AM
How do you do that?
I know this is a community forum, but it's about time you read the manual too, you know.... ;)

In CPanel, go to MySQL Databases, under Current Users, create a new user, then below it, add user to database using the drop-downs. This is with CPanel X, I don't know what interface you have but you get the idea ....

sdjl
08-30-2006, 03:00 PM
Exactly as nadzri states

airoid
08-30-2006, 03:28 PM
I think he is referring to being able to access the database through phpmyadmin. You can't login to phpmyadmin with the mysql user accounts....can you?

chabbs
08-30-2006, 03:31 PM
I know this is a community forum, but it's about time you read the manual too, you know.... ;)

In CPanel, go to MySQL Databases, under Current Users, create a new user, then below it, add user to database using the drop-downs. This is with CPanel X, I don't know what interface you have but you get the idea ....

I thought you were giving me information that I wasn't aware of. What you're suggesting doesn't solve anything because the programmer still has access to all the other databases. Please do not make any assumptions about me reading manuals because you have no clue if I have or haven't.

Let me re-state the question. I would like my programmer to access a database with all the permissions that are available but I would like to limit him to be able to access that database alone. Maybe he could do it remotely or maybe there's a way to give him access to only that database through PHPmyadmin. I don't want him to have access to any files or any other databases but that one alone. Is there a way to do this?

nadzri
08-31-2006, 02:29 AM
What you're suggesting doesn't solve anything because the programmer still has access to all the other databases.How and why? Does the programmer have some other access you're not telling us? You've given us a two-liner problem description and it seems that you expect a comprehensive step-by-step solution.

I thought you were giving me information that I wasn't aware of. Please do not make any assumptions about me reading manuals because you have no clue if I have or haven't.
Funny thing... I reread this thread and I agree with myself ;) - your responses strongly indicate to me that you have not RTFM.

My mistake then. I know the forum sticky said to post solutions only in this forum, but I honestly thought that by answering the OP it would indirectly turn this thread into a howto. Sorry ....

:)

airoid
08-31-2006, 02:53 AM
I understand chabbs question about allowing a user only to access one database in phpmyadmin, but I don't know if it is possible.

He has a valid question. This may not be the right forum category for it, but he deserves our help not our criticism.

chabbs
08-31-2006, 03:54 AM
You've given us a two-liner problem description and it seems that you expect a comprehensive step-by-step solution.

This is a help forum is it not? If I could not get a step by step solution then what is the purpose of asking a question. If someone cannot anwer a question then they just move on. If a person knows the answer to the question they could either provide the answer themsleves or direct the person to a source of information where the answer could be found. Since you have RTFM why don't you point me to the section that provides me the answer? :rolleyes: It would save you from having to write out a step by step solution.

How and why? Does the programmer have some other access you're not telling us?

If I make the programmer access my account through mydomain.com/cpanel, then go to the Mysql section, does he not still have access to the other databases? Even if I would have created a user with all permissions and added that user to the database what does that do to protect me from him being able to download the other databases? He could use the Cpanel back up feaure to make the back up of the other databases or access PHPmydmin and create a back up there. The account has shell access, he could also run the command mysqldump -u username -ppassword databasename > database.sql where it would save the database on the server and then he could ftp the database down to his PC.

I had done a comprehensive search on the Web before posting here. I was hoping that either someone from the hosting company knew the answer or maybe someone else had the answer. I didn't want to go directly to Customer Support because if there was a solution then maybe the answer could have helped someone else in the future and seeing that the question is not urgent I didn't want to tie up a rep with my question.

nadzri
08-31-2006, 04:58 AM
I understand chabbs question about allowing a user only to access one db in phpmyadmin, but I don't know if it is possible.
I didn't, I did not see anywhere that he stated he wants to give access through phpmyadmin. And from what I've read, you can't even access phpmyadmin unless you have a Cpanel account. However, you can install your own copy of phpmyadmin.

If I make the programmer access my account through mydomain.com/cpanel, then go to the Mysql section, does he not still have access to the other databases? Even if I would have created a user with all permissions and added that user to the database what does that do to protect me from him being able to download the other databases?
You are supposed to log into CPanel and give him db access. Recap: part of cpanel manual here (http://www.cpanel.net/docs/cpanel/Grant_a_user_s_permissions_to_a_MySQL_database.htm ). If you've only given him access to that particular db, then he won't be able to access other db's. The username and password you created to access that db will only be valid for that db alone. Ok? (This is all assuming you do not give him shell/cpanel access.) No way you can expect a step-by-step when you ask with a simple two-liner like in your op.

hth. :confused: :eek:

chabbs
08-31-2006, 05:30 AM
Ok, maybe I'm dense, please be patient.

The username and password you created to access that db will only be valid for that db alone. Ok?

At the bottom of that page where you find all the MySql databases there's a link to phpmyadmin. Even if I create a user specifcally for him and he accesses phpmyadmin then he still has access to the other databases doesn't he? The access that I give him through cpanel gives him permission for the whole account exposing all the files and databases.

nadzri
08-31-2006, 05:49 AM
Giving him access to a specific db does not give him access to phpmyadmin at all. And it shouldn't give him access to cpanel either unless you've given him additional permission. Cpanel does not give you access to phpmyadmin except through, and only through, Cpanel. Your programmer will have to access the db via some script like php or perl, and this can include your own installation of phpmyadmin.

To reiterate, giving him access to a specific db is not the same as giving him access to cpanel or shell.

May I ask - what do you want him to do, and what else are you concerned about? If you're more descriptive, you'll find that people may be more willing to help. TBH, earlier you just came across like a smug noob to me. Hehe, sorry about that, no offence. :)

chabbs
08-31-2006, 06:12 AM
May I ask - what do you want him to do, and what else are you concerned about?

We've developed a program that uses a database. The progam is available to the public but is still in beta. Occassionally we discover a bug and sometimes it stems from a glitch in the database or by people using characters that are not allowed in MySql like the period that wasn't dealt with in the programming. To troubleshoot he needs to see what is happening in the database and make the adjustment in the database and the programming.

I have given him access to the files through restricted FTP access. He is able to download and upload within that folder all he wants, but because he doesn't have access to the database through cpanel he is limited in his troubleshooting. The access that he needs to the database must give him the same access as if he was in phpmyadmin.

sdjl
08-31-2006, 06:37 AM
Your original question didn't mention anything about phpmyadmin access or similar, so i thought along the same lines of nadzri here.

Simple way to get what you want is do the following.

1) Create a new username and password for MySQL under cPanel.
2) Assign that username and password to the MySQL database you want your programmer to have access to only.
3) Download a new copy of phpmyadmin from http://www.phpmyadmin.net/home_page/index.php
4) Install it following the instructions found within the tarball/zip file
5) Give your programmer access to that copy of phpmyadmin.

Just to reiterate what nadrzi has stated: The more detail you put in your questions, the better answers you will get. It will also get you an answer in a few responses, rather than a 3 page essay, to do something simple like above.

Good luck :)

David

nadzri
08-31-2006, 06:43 AM
Well, I see a few choices.

1. You do your original idea that is to create another site with cpanel account etc.

2. Install your own phpmyadmin.

3. Give him shell access via shell, not create a new user via cpanel. ("man useradd/adduser" to find out, in shell). Then he will be able to invoke the mysql client.

4. Ask him to use Mysql Query Browser or another mysql client such as MysqlFront.

Given your restrictions, I'd go with option 2 or 4. For option 2, you can probably set up a separate site to install on, but on the same server. For option 4 you will need to enable host access too in the "MySQL Databases" section in Cpanel. If he has a fixed IP, all the better.

Why not option 1? It's doable but I don't want him to "own" an account.

chabbs
08-31-2006, 06:52 AM
Thank you all for your responses. That's enough info for me to do what I need.

The more detail you put in your questions, the better answers you will get. It will also get you an answer in a few responses, rather than a 3 page essay, to do something simple like above.

That's the problem with assumption. You sometimes think the other people will understand what you're talking about in just a few words. Thanks for the tip.

sdjl
08-31-2006, 08:16 AM
That's ok.

It should be fairly simple to setup, it's mainly just editing config.inc.php to include the right username, password and database with phpmyadmin.

David