带您深入了解MySQL权限管理

树叶云

不同的权限在MySQL数据库上能进行的操作是不同的,下面就为您介绍MySQL权限管理的一些知识,如果您对MySQL权限管理方面感兴趣的话,不妨一看。

========对于ROOT用户的密码操作(更改用户密码)========
刚刚安装完的MySQL,MySQL权限管理上只一有个root用户,密码为空,而且只能在本机登录!

为root加上密码xxx123:
./bin/mysqladmin -u root password xxx123
或写成
./bin/mysqladmin -uroot password xxx123

加下密码之后,在本进行进入mysql:
./bin/mysql -uroot -p

更改root的密码由xxx123改为yy1234:
./bin/mysqladmin -uroot -pxxx123 password yy1234

=======grant 权限 on 数据库对象 to 用户==========
MySQL 赋予用户权限命令的简单格式可概括为:
grant 权限 on 数据库对象 to 用户
grant 权限 on 数据库对象 to 用户 identified by “密码”

========用户及权限管理:最常用操作实例========
(用户名:dba1,密码:dbapasswd,登录IP:192.168.0.10)

//开放管理MySQL中所有数据库的权限
grant all on *.* to dba1@’192.168.0.10’identified by “dbapasswd”;

//开放管理MySQL中具体数据库(testdb)的权限
grant all privileges on testdb to dba1@’192.168.0.10’identified by “dbapasswd”;

grant all on testdb to dba1@’192.168.0.10’identified by “dbapasswd”;

//开放管理MySQL中具体数据库的表(testdb.table1)的权限
grant all on testdb.teable1 to dba1@’192.168.0.10’identified by “dbapasswd”;

//开放管理MySQL中具体数据库的表(testdb.table1)的部分列的权限
grant select(id, se, rank) on testdb.table1 to ba1@’192.168.0.10’identified by “dbapasswd”;

//开放管理操作指令
grant select, insert, update, delete on testdb.* to dba1@’192.168.0.10’identified by “dbapasswd”;

//回收权限
revoke all on *.* from dba1@localhost;

//查看 MySQL 用户权限
show grants;
show grants for dba1@localhost;
 

以上就是MySQL权限管理的介绍。

 

 

【编辑推荐】

教您如何mysql索引优化

mysql索引比较分析

MySQL索引的用处

mysql索引的不足

MySql连接字符串的说明

文章来源网络,作者:运维,如若转载,请注明出处:https://shuyeidc.com/wp/228842.html<

(0)
运维的头像运维
上一篇2025-04-18 12:02
下一篇 2025-04-18 12:03

相关推荐

发表回复

您的邮箱地址不会被公开。必填项已用 * 标注