mysql创建新用户和授权指定数据库权限

windows环境,mysql版本5.7.*

问题描述

mysql创建新用和授权数据库权限,要给mysql的某个用户授权远程链接数据库,并且授权一些操作权限。

mysql命令登录,账号root,密码:12345678910

Microsoft Windows [版本 10.0.19043.1288]
(c) Microsoft Corporation。保留所有权利。

C:\Users\Administrator>mysql -u root -p
Enter password: ******
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 74
Server version: 5.7.26 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

命令行

以下命令由Navicat自动创建。

CREATE USER `thinkphp`@`%` IDENTIFIED WITH mysql_native_password BY '123456';

创建用户:thinkphp。

通配符%表示该用户可以从任意远程主机登陆。

密码:123456。

操作权限授权

thinkphp库授权给用户:thinkphp

GRANT Alter, Alter Routine, Create, Create Routine, Create Temporary Tables, Create View, Delete, Drop, Event, Execute, Grant Option, Index, Insert, Lock Tables, References, Select, Show View, Trigger, Update ON `thinkphp`.* TO `thinkphp`@`%`;

刷新授权

flush privileges;

授权可能无法立刻生效。

点赞(1) 打赏

评论列表 共有 0 条评论

暂无评论

微信小程序

微信扫一扫体验

立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部