Results 1 to 2 of 2
  1. #1

    Default How to create new user in MySQL and grant permission to him

    I want to create 2 new users in MySQL. What are the most required steps to do it. thanks in advance.

  2. #2
    Join Date
    May 2013
    Posts
    13

    Default

    Quote Originally Posted by FirePro View Post
    I want to create 2 new users in MySQL. What are the most required steps to do it. thanks in advance.
    Hi,

    Go to Shell :

    1) CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';

    Currently newuser has no permissions to do anything with the databases.

    2) GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';

    The asterisks in this command refer to the database and table (respectively) that they can access—this specific command allows to the user to read, edit, execute and perform all tasks across all the databases and tables.

    Once you have finalized the permissions that you want to set up for your new users, always be sure to reload all the privileges.

    3) FLUSH PRIVILEGES;

    Your changes will now be in effect.

    To provide a specific user with a permission, you can use this framework:

    4) GRANT [type of permission] ON [database name].[table name] TO ‘[username]’@'localhost’;

    If you want to give them access to any database or to any table, make sure to put an asterisk (*) in the place of the database name or table name.

    Each time you update or change a permission be sure to use the Flush Privileges command.

    If you need to revoke a permission, the structure is almost identical to granting it:

    5) REVOKE [type of permission] ON [database name].[table name] TO ‘[username]’@‘localhost’;

    Just as you can delete databases with DROP, you can use DROP to delete a user altogether:

    6) DROP USER ‘demo’@‘localhost’;

    To test out your new user, log out by typing
    quit

    and log back in with this command in terminal:

    mysql -u [username]-p

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •