Question

I have a MySQL database that has several databases used by more than 1 web app.

I need to now create a new Database that can only be accessed via a new user account. I've been using Navicat v5.3.3 manage users to try to set this up but it doesn't seem to work and I don't know if that's bec of MySQL or Navicat.

But given that I want a new DB that a new account can only access (not the other dbs) what's the best way to set this up?

Thanks

Was it helpful?

Solution

You just have to create your database and grant to the user the desired privileges, you should start a mysql query tool and type following queries:

CREATE DATABASE foobar;
GRANT ALL PRIVILEGES ON foobar.* TO 'foobar_user'@'localhost'
IDENTIFIED BY 'goodsecret';

you can take a look at the MySQL manual here

OTHER TIPS

I'd usually use phpMyAdmin or the MySQL command-line interface. Create the database and (using your superuser account), make sure the user has appropriate permissions on that database.

Something like:

CREATE DATABASE database_name;
GRANT ALL ON database_name.* TO new_user@'localhost' IDENTIFIED BY 'password';

That will give 'new_user' all privileges over the contents of database_name, provided that user is connected from localhost using 'password'.

If you want a GUI though - I highly recommend phpMyAdmin (http://www.phpmyadmin.net/)

EDIT: Based on your description, you'll also want to make sure the permissions on the other databases are set to prevent this new user accessing them; you can use 'SHOW GRANTS' to see which users have privileges over which tables - see http://en.wikipedia.org/wiki/Internet_Explorer_box_model_bug

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top