473,406 Members | 2,356 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,406 software developers and data experts.

how to give permissions for the user to create a database

147 100+
I am creating a USER in ROOT :

grant all privileges on databasename.* to username@localhost identified by 'password';
Now,i am logging through my username :

mysql -u username -p
Enter password : password

Now, i am trying to create a database :

mysql>create database sample;
it showing an error :

Access denied for user 'username'@'localhost' to database 'sample'
Jan 15 '10 #1
4 2402
mwasif
802 Expert 512MB
User will only be able to create database named databasename.
Jan 15 '10 #2
Atli
5,058 Expert 4TB
To elaborate on mwasif's point...

You define in your GRANT statement's ON clause which databases the user can use. Any database you do not specify will not be accessible, whether it currently exists or not.

So, because you do:
Expand|Select|Wrap|Line Numbers
  1. GRANT ALL PRIVILEGES ON databasename.* ...
your user only has access to the database named "databasename". Trying to create - or in any other way use - another database will fail with the error you posted.

If you want the user to have access to another database, you will need to issue another GRANT statement for that database, or give the user global access by using the wild-card char (*).
Expand|Select|Wrap|Line Numbers
  1. GRANT ALL PRIVILEGES ON *.* ...
Be careful with this though, because it gives the user access to all databases, tables and columns, which is usually not a good idea.
Jan 16 '10 #3
santhanalakshmi
147 100+
thanks for ur reply.....if we give GRANT permissions for a user to access a particular database means then that the user cannot create a new database.Its correct na.

we should follow,if the user want to create a new database means...

GRANT ALL PRIVILEGES *.* .....
Jan 18 '10 #4
Atli
5,058 Expert 4TB
If you want a user to be able to create whatever databases he likes, then you need to go with the "ON *.*" clause, yes. Just keep in mind that this does give him access to every database on the server, regardless of who created it or when it was/will be created.

You can, however, grant him access to databases that don't yet exist. The GRANT clause doesn't care about that. So if a user is mean to be able to create a set of tables - like say: if you are creating a user for a setup script that sets up it's own databases - then you can GRANT him access to them ahead of time.
Jan 18 '10 #5

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

Similar topics

10
by: Shelly | last post by:
I have a new server and I have my files up there. The files are in /var/www/html/. In this directory I have another directory that I created called "users". I am unable to figure out how to set...
0
by: Fran Tirimo | last post by:
I am developing a small website using ASP scripts to format data retrieved from an Access database. It will run on a Windows 2003 server supporting FrontPage extensions 2002 hosted by the company...
2
by: Fran Tirimo | last post by:
I am developing a small website using ASP scripts to format data retrieved from an Access database. It will run on a Windows 2003 server supporting FrontPage extensions 2002 hosted by the company...
5
by: Ross Presser | last post by:
As our customers demand that we tighten our IT security in the company, I've been asked to prepare a report quarterly showing, for each user in Active directory, what his effective permissions are...
16
by: Lyle Fairfield | last post by:
There is an MS-SQL table named Bugs_Comments_and_Suggestions. There is a form named Bugs_Comments_and_Suggestions. To allow John Doe to use this form, we GRANT him LOGIN and ACCESS permissions...
5
by: Control Freq | last post by:
Hi I connect to my MySQL database using MyODBC. I have a table called 'log' in a database called 'home'. When I try to do an insert like this: insert into log (userid,event,event_date) values...
3
by: palepimp | last post by:
Hello all, I have searched far and wide for a solution to my issue. In short, here is the problem: 1. 3 PC's enter data into an Access 2003 database (PC's are running Vista w/ Office 2007...
6
by: DotNetNewbie | last post by:
Hello, in my web application, I have to create permissions for each user. So what I am doing is that for each role (using sqlmembership in .net) I am creating a column in the database to hold a...
0
by: owuraku | last post by:
I appreciate the help you guys (especially Adezii) have given me thus far. I have one more question to help me complete my database. I am trying to use DAO to programmatically assign permissions to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.