2

i all

i was able to assign privilege to create new database to a user with

root> GRANT CREATE ON *.* TO 'newuser'@'localhost';
newuser> create database newdb;
newuser> Query OK, 1 row affected (0.00 sec)

now, i would that the newdb just created by 'newuser' was writable by newuser itself.

newuser> CREATE TABLE newtable ( id INT );
Query OK, 0 rows affected (0.00 sec)
newuser> INSERT INTO newtable (id) VALUES (1);
ERROR 1142 (42000): INSERT command denied to user 'offique'@'localhost' for table 'newtable'

i try to set privileges (with same user...) without solution :-(

newuser> GRANT ALL PRIVILEGES ON newdb.* TO 'newuser'@'localhost';
ERROR 1044 (42000): Access denied for user 'newuser'@'localhost' to database 'newdb'

any idea?

many thanks!

5
  • Did you FLUSH PRIVILEGES after using the GRANT command? dev.mysql.com/doc/refman/5.0/en/flush.html Commented Nov 25, 2011 at 0:48
  • thanks dak but it would be unhelpful... GRANT command cames out not well... (ERROR 1044 (42000): Access denied) Commented Nov 25, 2011 at 0:59
  • With GRANT CREATE ON *.* TO 'newuser'@'localhost'; you give the CREATE privilege to newuser when he connects from localhost. Have you tried granting him all the privileges? Commented Nov 25, 2011 at 1:03
  • You need to be root when adding privileges to newuser - because newuser only has the CREATE right. So, root> GRANT ALL PRIVILEGES ON newdb.* TO 'newuser'@'localhost' WITH GRANT OPTION; should have given the newuser all privileges on newdb Commented Nov 25, 2011 at 1:13
  • then... is impossible to a new user create database himself and write in without passing for root user (that giving privileges)? Commented Nov 25, 2011 at 6:28

1 Answer 1

1

now, i would that the newdb just created by 'newuser' was writable by newuser itself.

In this case it is enought to give an INSERT privilege on database level -

GRANT INSERT ON *.* TO 'newuser'@'localhost';

You should grant it from the 'root' account, because your new user has no rights to do it itself.


GRANT INSERT ON newdb.* TO 'newuser'@'localhost';
Sign up to request clarification or add additional context in comments.

2 Comments

thanks Devart. But in this case newuser have access to all databases. I would that newuser have access only to database create itself.
@Roberto Oh, sorry. I missed it. I changed the answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.