mysql怎么授权,mysql怎么授权用户

如何设置mysql用户的权限

1、创建新用户

10年积累的成都网站建设、做网站经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站设计后付款的网站建设流程,更有泰宁免费网站建设让你可以放心的选择与我们合作。

通过root用户登录之后创建

grant all privileges on *.* to testuser@localhost identified by "123456" ;//创建新用户,用户名为testuser,密码为123456 ;

grant all privileges on *.* to testuser@localhost identified by "123456" ;//设置用户testuser,可以在本地访问mysql

grant all privileges on *.* to testuser@"%" identified by "123456" ; //设置用户testuser,可以在远程访问mysql

flush privileges ;//mysql 新设置用户或更改密码后需用flush privileges刷新MySQL的系统权限相关表,否则会出现拒绝访问,还有一种方法,就是重新启动mysql服务器,来使新设置生效

2、设置用户访问数据库权限

grant all privileges on test_db.* to testuser@localhost identified by "123456" ;//设置用户testuser,只能访问数据库test_db,其他数据库均不能访问 ;

grant all privileges on *.* to testuser@localhost identified by "123456" ;//设置用户testuser,可以访问mysql上的所有数据库 ;

grant all privileges on test_db.user_infor to testuser@localhost identified by "123456" ;//设置用户testuser,只能访问数据库test_db的表user_infor,数据库中的其他表均不能访问 ;

3、设置用户操作权限

grant all privileges on *.* to testuser@localhost identified by "123456" WITH GRANT OPTION ;//设置用户testuser,拥有所有的操作权限,也就是管理员 ;

grant select on *.* to testuser@localhost identified by "123456" WITH GRANT OPTION ;//设置用户testuser,只拥有【查询】操作权限 ;

grant select,insert on *.* to testuser@localhost identified by "123456" ;//设置用户testuser,只拥有【查询\插入】操作权限 ;

grant select,insert,update,delete on *.* to testuser@localhost identified by "123456" ;//设置用户testuser,只拥有【查询\插入】操作权限 ;

REVOKE select,insert ON what FROM testuser//取消用户testuser的【查询\插入】操作权限 ;

mysql怎么给予root权限

利用 GRANT 语句进行授权:

grant select on testdb.* to root@'%';

上述语句意思为只将对数据库testdb的查询权限授予root用户

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';

上述语句意思为将对所有数据库的所有权限都授权给root用户!

mysql怎么授予创建数据库的权限

MySQL命令行能否实现新建用户呢?答案无疑是肯定的。而且在使用使用MySQL命令行新建用户后,还可以为用户授予权限。

首先要声明一下:一般情况下,修改MySQL密码,授权,是需要有mysql里的root权限的。

注:本操作是在WIN命令提示符下,phpMyAdmin同样适用。

用户:phplamp

用户数据库:phplampDB

1.MySQL命令行新建用户

//登录MYSQL

@mysql -u root -p

@密码

//创建用户

mysql insert into mysql.user(Host,User,Password) values('localhost','phplamp',password('1234'));

//刷新系统权限表

mysqlflush privileges;

这样就创建了一个名为:phplamp 密码为:1234 的用户。

//退出后登录一下

mysqlexit;

@mysql -u phplamp -p

@输入密码

mysql登录成功

2.MySQL命令行为用户授权

//登录MYSQL(有ROOT权限)。我里我以ROOT身份登录.

@mysql -u root -p

@密码

//首先为用户创建一个数据库(phplampDB)

mysqlcreate database phplampDB;

//授权phplamp用户拥有phplamp数据库的所有权限

@grant all privileges on phplampDB.* to phplamp@localhost identified by '1234'; //这里需要注意,如果发现找不到用户,需要执行命令 flush privilieges;

//刷新系统权限表

mysqlflush privileges;

mysql其它操作

//如果想指定部分权限给一用户,可以这样来写:

mysqlgrant select,update on phplampDB.* to phplamp@localhost identified by '1234';

//刷新系统权限表。

mysqlflush privileges;

mysql grant 权限1,权限2,…权限n on 数据库名称.表名称 to 用户名@用户地址 identified by ‘连接口令’;

权限1,权限2,…权限n代表select,insert,update,delete,create,drop,index,alter,grant,references,reload,shutdown,process,file等14个权限。

当权限1,权限2,…权限n被all privileges或者all代替,表示赋予用户全部权限。

当数据库名称.表名称被*.*代替,表示赋予用户操作服务器上所有数据库所有表的权限。

用户地址可以是localhost,也可以是ip地址、机器名字、域名。也可以用’%'表示从任何地址连接。

‘连接口令’不能为空,否则创建失败。

例如:

mysqlgrant select,insert,update,delete,create,drop on vtdc.employee to joe@10.163.225.87 identified by ‘123′;

给来自10.163.225.87的用户joe分配可对数据库vtdc的employee表进行select,insert,update,delete,create,drop等操作的权限,并设定口令为123。

mysqlgrant all privileges on vtdc.* to joe@10.163.225.87 identified by ‘123′;

给来自10.163.225.87的用户joe分配可对数据库vtdc所有表进行所有操作的权限,并设定口令为123。

mysqlgrant all privileges on *.* to joe@10.163.225.87 identified by ‘123′;

给来自10.163.225.87的用户joe分配可对所有数据库的所有表进行所有操作的权限,并设定口令为123。

mysqlgrant all privileges on *.* to joe@localhost identified by ‘123′;

给本机用户joe分配可对所有数据库的所有表进行所有操作的权限,并设定口令为123。

Mysql--基本配置、授权及删除权限

Mac下安装与配置MySQL

启动Mysql服务端

启动Mysql客户端

mac偏好设置启动or关闭

复制cnf文件

配置文件路径 /etc/my.cnf

配置完成后,需要重启服务端才能生效

在您相应的配置文件里添加,.profile or .zshrc

网站标题:mysql怎么授权,mysql怎么授权用户
链接地址:https://www.cdcxhl.com/article16/hecsdg.html

成都网站建设公司_创新互联,为您提供关键词优化网站营销全网营销推广软件开发网站改版网站建设

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

网站托管运营