Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 10-06-2007, 01:00 PM   #1
Registered: Mar 2004
Distribution: Fedora Core 1,2,3, RHEL3,4,5 Ubuntu
Posts: 274

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?

Old 10-07-2007, 05:19 AM   #2
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, 07:45 AM   #3
Senior Member
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,450

Rep: Reputation: 1006Reputation: 1006Reputation: 1006Reputation: 1006Reputation: 1006Reputation: 1006Reputation: 1006Reputation: 1006
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
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
mysql --user=mysql --password=mysqlpassword < grant.sql
If you want to grant all permissions to a user, do this:
grant all privileges
on dbname.* to user@localhost
identified by 'userpassword';
flush privileges;
Again, save that in a file and execute as above.

Old 10-10-2007, 09:34 AM   #4
Registered: Mar 2004
Distribution: Fedora Core 1,2,3, RHEL3,4,5 Ubuntu
Posts: 274

Original Poster
Rep: Reputation: 30
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.
 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


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 03:04 PM
mysql - can't access mysql database as root yogaboy Linux - Software 5 12-28-2006 06:58 AM
Deny user access to terminal/directory browsing intranet_man Linux - Networking 2 03-22-2006 12:04 PM
how to deny user to use ftp to access system ust Linux - Software 4 05-23-2005 08:39 PM
MySQL Cannot Access Database ChineseElite Linux - General 13 11-27-2002 08:30 PM

All times are GMT -5. The time now is 01:32 PM.

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