LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 10-06-2007, 02:00 PM   #1
blizunt7
Member
 
Registered: Mar 2004
Distribution: Fedora Core 1,2,3, RHEL3,4,5 Ubuntu
Posts: 272

Rep: Reputation: 30
mySQL deny user access to database


Hey all,
New to mySQL, but trying to create users who are allowed only certain access to certain databases.
Tried setting grants from terminal, as well setting permissions from phpmyAdmin.
But for some reason all users have privileges to all databases.

Can anyone help to provide me with just some basic commands to set up and database, and only allow access to a specific user?


THanks!!!
 
Old 10-07-2007, 06:19 AM   #2
linuxjamil
Member
 
Registered: Dec 2005
Distribution: Fedora Core 5, Sun Solaris 8
Posts: 122

Rep: Reputation: 15
Lightbulb Regarding mysql access

Dear blizunt7

Would u please mention what command u used to grant a user specific access to a specific database ? I do believe to remedy the problem


Subrun Jamil
 
Old 10-07-2007, 08:45 AM   #3
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,121

Rep: Reputation: 819Reputation: 819Reputation: 819Reputation: 819Reputation: 819Reputation: 819Reputation: 819
If you only want a user to have select permission; i.e., the user can see but not change any information, you can grant that with
Code:
grant select
on dbname.*
to username@localhost identified by 'userpassword';
flush privileges;
Replace dbname with the name of the data base, username with the user's name, etc.

You must do this as the administrative user; i.e., mysql, using the password you set for user mysql -- save the above in a file, grant.sql or something and execute
Code:
mysql --user=mysql --password=mysqlpassword < grant.sql
If you want to grant all permissions to a user, do this:
Code:
grant all privileges
on dbname.* to user@localhost
identified by 'userpassword';
flush privileges;
Again, save that in a file and execute as above.

See http://dev.mysql.com/doc/refman/5.0/en/grant.html
 
Old 10-10-2007, 10:34 AM   #4
blizunt7
Member
 
Registered: Mar 2004
Distribution: Fedora Core 1,2,3, RHEL3,4,5 Ubuntu
Posts: 272

Original Poster
Rep: Reputation: 30
Hey,
As root, I created the user, and created a database, and then granted that user all permissions on that database. But from phpmyadmin that user cannot create new databases.
Code:
 mysql> GRANT ALL ON database_name.* TO user@'%';    // host = % (null = any host)
 mysql> GRANT ALL ON database_name.* TO user@'localhost';
So I just need to figure out how to give them permissions to create a new data base, but NOT view all databases.

THanks much
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
deny a user access to specific command krock923 Linux - Security 7 10-11-2012 04:04 PM
mysql - can't access mysql database as root yogaboy Linux - Software 5 12-28-2006 07:58 AM
Deny user access to terminal/directory browsing intranet_man Linux - Networking 2 03-22-2006 01:04 PM
how to deny user to use ftp to access system ust Linux - Software 4 05-23-2005 09:39 PM
MySQL Cannot Access Database ChineseElite Linux - General 13 11-27-2002 09:30 PM


All times are GMT -5. The time now is 07:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration