Home  >  Article  >  Database  >  带您深入了解MySQL权限管理

带您深入了解MySQL权限管理

WBOY
WBOYOriginal
2016-06-07 14:52:16951browse

不同的权限在MySQL数据库上能进行的操作是不同的,下面就为您介绍MySQL权限管理的一些知识,如果您对MySQL权限管理方面感兴趣的话,不妨一看。 ========对于ROOT用户的密码操作(更改用户密码)======== 刚刚安装完的MySQL,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权限管理的介绍。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn