MySql grant user permission

后端 未结 4 1966
既然无缘
既然无缘 2021-01-06 08:58

I want to create a new user in MySql. I do not want that new user to do much with my existing databases [I just want to grant Select privilege to him], but he can do anythin

4条回答
  •  半阙折子戏
    2021-01-06 09:21

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

    For more about permission you can read this article https://www.digitalocean.com/community/articles/how-to-create-a-new-user-and-grant-permissions-in-mysql

    For the list of permissions, see the MySQL Manual page Privileges Provided by MySQL.

提交回复
热议问题