List:General Discussion« Previous MessageNext Message »
From:Uma Bhat Date:April 23 2009 6:33am
Subject:Re: Creating / Lookup Users For Database
View as plain text  
Carlos,

1) To list the users having access to a database,
mysql> SELECT user,host from mysql.db where db = "*<database_name>*";

In your case that would be
mysql> SELECT user,host from mysql.db where db = "*cal*";


2) To grant access to a *NEW *user, you can use GRANT statement along with
IDENTIFIED BY clause, which creates a new user and grants specified
privileges to the specified database, in a single statement.


Hence to create a new user, you could use either of the following -

mysql> CREATE USER 'carlos'@'localhost' IDENTIFIED BY 'p@$$w3rd';
mysql> GRANT ALL PRIVILEGES ON forums.* TO 'carlos'@'localhost'  WITH GRANT
OPTION;

*OR*
**
mysql> GRANT ALL PRIVILEGES ON forums.* TO 'carlos'@'localhost'  IDENTIFIED
BY 'p@$$w3rd'  WITH GRANT OPTION;

Regards,
Uma Bhat



On 4/22/09, Carlos Williams <carloswill@stripped> wrote:
>
> This seems to be a simple beginer question for MySQL and I have
> searched online but I wanted to ask before I really confuse myself.
>
> I have MySQL running on Linux and right now I have created a 2nd
> production database:
>
> mysql> show databases;
> +-----------------------------+
> | Database                |
> +-----------------------------+
> | information_schema |
> | cal                          |
> | forums                    |
> | mysql                     |
> +-----------------------------+
>
> I know when I created 'cal' I also created a specific user to have
> permissions to this database as I was told root was not a good idea. I
> don't remember who or what user I created so can someone please tell
> me how I am able to look up the user who has permissions to 'cal'
> database and I would also like to have that same user permissions to
> the new database I created called 'forums'.
>
> Sorry for my ignorance but I greatly appreciate any and all assistance
> to my question above!
>
> --
> Carlos W.
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/mysql?unsub=1
>
>

Thread
Creating / Lookup Users For DatabaseCarlos Williams22 Apr
  • Re: Creating / Lookup Users For DatabaseUma Bhat23 Apr
Re: Creating / Lookup Users For DatabaseCarlos Williams22 Apr
  • Re: Creating / Lookup Users For DatabaseGeorge Larson22 Apr
    • Re: Creating / Lookup Users For DatabaseCarlos Williams22 Apr
      • Re: Creating / Lookup Users For DatabaseCarlos Williams22 Apr
        • Re: Creating / Lookup Users For DatabaseGeorge Larson22 Apr