Skip to content

Instantly share code, notes, and snippets.

@stormwild
Last active December 7, 2023 04:15
Show Gist options
  • Save stormwild/7d2d19fddf14055f03f7 to your computer and use it in GitHub Desktop.
Save stormwild/7d2d19fddf14055f03f7 to your computer and use it in GitHub Desktop.

Revisions

  1. stormwild revised this gist Aug 3, 2015. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions mysql-create-new-user-grant-permissions.md
    Original file line number Diff line number Diff line change
    @@ -18,6 +18,7 @@ Once you have finalized the permissions that you want to set up for your new use
    Your changes will now be in effect.

    How To Grant Different User Permissions
    =======================================

    Here is a short list of other common possible permissions that users can enjoy.

  2. stormwild revised this gist Aug 3, 2015. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions mysql-create-new-user-grant-permissions.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    How to Create a New User
    ========================

    ```CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';```

  3. stormwild revised this gist Aug 3, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mysql-create-new-user-grant-permissions.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    **How to Create a New User
    How to Create a New User

    ```CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';```

  4. stormwild revised this gist Aug 3, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mysql-create-new-user-grant-permissions.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    ** How to Create a New User
    **How to Create a New User

    ```CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';```

  5. stormwild revised this gist Aug 3, 2015. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions mysql-create-new-user-grant-permissions.md
    Original file line number Diff line number Diff line change
    @@ -49,3 +49,11 @@ To test out your new user, log out by typing

    ``` quit ```

    and log back in with this command in terminal:

    ``` mysql -u [username]-p ```

    By Etel Sverdlov

    Reference:
    [How To Create a New User and Grant Permissions in MySQL](https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql)
  6. stormwild revised this gist Aug 3, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mysql-create-new-user-grant-permissions.md
    Original file line number Diff line number Diff line change
    @@ -47,5 +47,5 @@ Just as you can delete databases with DROP, you can use DROP to delete a user al

    To test out your new user, log out by typing

    ```quit```
    ``` quit ```

  7. stormwild revised this gist Aug 3, 2015. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion mysql-create-new-user-grant-permissions.md
    Original file line number Diff line number Diff line change
    @@ -45,4 +45,7 @@ Just as you can delete databases with DROP, you can use DROP to delete a user al

    ```DROP USER ‘demo’@‘localhost’;```

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

    ```quit```

  8. stormwild revised this gist Aug 3, 2015. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions mysql-create-new-user-grant-permissions.md
    Original file line number Diff line number Diff line change
    @@ -44,3 +44,5 @@ If you need to revoke a permission, the structure is almost identical to grantin
    Just as you can delete databases with DROP, you can use DROP to delete a user altogether:

    ```DROP USER ‘demo’@‘localhost’;```

    To test out your new user, log out by typing
  9. stormwild revised this gist Aug 3, 2015. 1 changed file with 0 additions and 13 deletions.
    13 changes: 0 additions & 13 deletions mysql-create-new-user-grant-permissions.md
    Original file line number Diff line number Diff line change
    @@ -44,16 +44,3 @@ If you need to revoke a permission, the structure is almost identical to grantin
    Just as you can delete databases with DROP, you can use DROP to delete a user altogether:

    ```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```


    -------------------------------------------
    Reference:
    [How To Create a New User and Grant Permissions in MySQL](https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql)
  10. stormwild revised this gist Aug 3, 2015. 1 changed file with 5 additions and 4 deletions.
    9 changes: 5 additions & 4 deletions mysql-create-new-user-grant-permissions.md
    Original file line number Diff line number Diff line change
    @@ -39,15 +39,16 @@ Each time you update or change a permission be sure to use the Flush Privileges

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

    ```REVOKE [type of permission] ON [database name].[table name] FROM ‘[username]’@‘localhost’;```
    ```REVOKE [type of permission] ON [database name].[table name] FROM ‘[username]’@‘localhost’;```

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

    ```DROP USER ‘demo’@‘localhost’;```
    ```DROP USER ‘demo’@‘localhost’;```

    To test out your new user, log out by typing

    ```quit```
    ```quit```

    and log back in with this command in terminal:

    ```mysql -u [username]-p```
  11. stormwild revised this gist Aug 3, 2015. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion mysql-create-new-user-grant-permissions.md
    Original file line number Diff line number Diff line change
    @@ -50,7 +50,8 @@ To test out your new user, log out by typing

    and log back in with this command in terminal:

    ```mysql -u [username]-p
    ```mysql -u [username]-p```


    -------------------------------------------
    Reference:
  12. stormwild revised this gist Aug 3, 2015. 1 changed file with 20 additions and 0 deletions.
    20 changes: 20 additions & 0 deletions mysql-create-new-user-grant-permissions.md
    Original file line number Diff line number Diff line change
    @@ -33,5 +33,25 @@ To provide a specific user with a permission, you can use this framework:

    ```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:

    ```REVOKE [type of permission] ON [database name].[table name] FROM ‘[username]’@‘localhost’;```

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

    ```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

    -------------------------------------------
    Reference:
    [How To Create a New User and Grant Permissions in MySQL](https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql)
  13. stormwild revised this gist Aug 3, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mysql-create-new-user-grant-permissions.md
    Original file line number Diff line number Diff line change
    @@ -34,4 +34,4 @@ To provide a specific user with a permission, you can use this framework:
    ```GRANT [type of permission] ON [database name].[table name] TO ‘[username]’@'localhost’;```

    Reference:
    [https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql](How To Create a New User and Grant Permissions in MySQL)
    [How To Create a New User and Grant Permissions in MySQL](https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql)
  14. stormwild revised this gist Aug 3, 2015. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions mysql-create-new-user-grant-permissions.md
    Original file line number Diff line number Diff line change
    @@ -1,18 +1,18 @@
    ** How to Create a New User

    CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
    ```CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';```

    newuser has no permissions to access any databases nor to login to MySQL shell.

    Provide access to new user:

    GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';
    ```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.

    FLUSH PRIVILEGES;
    ```FLUSH PRIVILEGES;```

    Your changes will now be in effect.

    @@ -31,7 +31,7 @@ Here is a short list of other common possible permissions that users can enjoy.

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

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

    Reference:
    [https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql](How To Create a New User and Grant Permissions in MySQL)
  15. stormwild created this gist Aug 3, 2015.
    37 changes: 37 additions & 0 deletions mysql-create-new-user-grant-permissions.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    ** How to Create a New User

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

    newuser has no permissions to access any databases nor to login to MySQL shell.

    Provide access to new user:

    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.

    FLUSH PRIVILEGES;

    Your changes will now be in effect.

    How To Grant Different User Permissions

    Here is a short list of other common possible permissions that users can enjoy.

    * ALL PRIVILEGES- as we saw previously, this would allow a MySQL user all access to a designated database (or if no database is selected, across the system)
    * CREATE- allows them to create new tables or databases
    * DROP- allows them to them to delete tables or databases
    * DELETE- allows them to delete rows from tables
    * INSERT- allows them to insert rows into tables
    * SELECT- allows them to use the Select command to read through databases
    * UPDATE- allow them to update table rows
    * GRANT OPTION- allows them to grant or remove other users' privileges

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

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

    Reference:
    [https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql](How To Create a New User and Grant Permissions in MySQL)