MySql grant user permission

后端 未结 4 1982
既然无缘
既然无缘 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:26

    Open mysql command prompt.

    To create a new user when host is localhost then use this command

    CREATE user 'test_user'@'localhost' identified by 'some_password';
    

    for any host use %, like this

    CREATE user 'test_user'@'%' identified by 'some_password';
    

    Once the user is created, you need to Grant some access. Use following command for this.

    GRANT SELECT,INSERT,UPDATE
    ON database_name.table_name
    TO 'test_user'@'localhost';
    

    After successful execution of above query, test_user can select, insert and update in table_name (name of table) of database_name (name of database).

提交回复
热议问题