MYSQL basic user permissions

MYSQL basic user permissions

 Grant Different User Permissions On a MYSQL database.

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’;

e.g. GRANT ALL PRIVILEGES ON test_db .* TO 'test-db-user'@'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.

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’;

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
    • Related Articles

    • MySQL

      MySQL     Log into MySQL: mysql -uUSERNAME -p'PASSWORD' List Users: SELECT User FROM mysql.user; Create & Modify Users: CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost'; Once you have ...
    • Reset mysql password

      First try to see if you can login to mysql as root. ssh to root user, or su root from AD login.       mysql If you get an error similar to: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) Then the password is ...
    • Joomla/WordPress/CMS Permissions

      With the way that Hsphere and cPanel work in our shared environments, all CMS permissions should be set as follows: Directories - 755 Files - 644 If permissions have been changed or if you're unsure which permissions are which, you can run the ...
    • How do I backup a MySQL database?

      Backing up your MySQL database can be done couple different ways. Method #1 Using the phpMyAdmin web interface included in the Hsphere CP Method #2 Using command line utility "mysqldump" Using the phpMyAdmin Method: To access phpMyAdmin, you will ...
    • HSphere Plan Access: You Have No Permissions On This Plan

      If you try to resume a suspended account from your Reseller Account and get: Error: You have no permissions on this plan Check that the Plan for the end user account in question has full permissions set. Go to Plans tab: If next to the lock icon for ...