Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I've installed Ubuntu 12.10(quantal) and mysql-server-5.5.

When I execute:

drop user ''@'localhost';
create database `redmine`;
grant all on `redmine`.* to 'redmine'@'localhost';

User redmine@localhost can access not only redmine database, but also other databases.

How do I prevent him from accessing any database except redmine?

P.S. I can't reproduce this on other distributions. What is a proper behaviour? Is this a bug?

UPDATE1:

mysql> show grants;
+--------------------------------------------------------------+
| Grants for redmine@localhost |
+--------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'redmine'@'localhost' |
| GRANT ALL PRIVILEGES ON `redmine`.* TO 'redmine'@'localhost' |
+--------------------------------------------------------------+
2 rows in set (0.00 sec)

mysql> use test;
Database changed
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| x |
+----------------+
1 row in set (0.00 sec)
share|improve this question

migrated from superuser.com Jun 9 '12 at 4:43

This question came from our site for computer enthusiasts and power users.

2 Answers 2

The grants you gave on the redmine database have nothing to do with access to the test database.

The problem is the way mysql was installed. It allows full access to the test database. It is not a bug. I wrote a past post (Question and Answer) on why anybody can access a test database and how to fix it:

In essence, the problem is the table mysql.db. It contains entries that allow everyone and his grandmother to do anything in a test database or any database whose first five characters are test_. Removing those entries with DELETE FROM mysql.db WHERE LEFT(db,4)='test'; will immediately solve your particular problem.

I have other posts on how to thoroughly strip anonymous users from mysql.user and why

Please read these carefully because my past answers will show you things like

SELECT USER(),CURRENT_USER();

This will break down the difference between how you logged in and how mysqld allowed you to login.

share|improve this answer

You can verify by connecting using 'redmine'@'localhost' and see how many databases by executing this query:

Show databases;

Also, you can execute another query to see exactly what are privileges given to 'redmine'@'localhost':

show grants for 'redmine'@'localhost';

share|improve this answer
    
I did all that. Updating question for clarity. –  Basilevs Jun 9 '12 at 16:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.