========对于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
)
.1) 开放管理MySQL中所有数据库的权限
grant all on *.* to dba1@'192.168.0.10'identified by "dbapasswd";
.2) 开放管理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";
.3)开放管理MySQL中具体数据库的表(testdb.table1)的权限
grant all on testdb.teable1 to dba1@'192.168.0.10'identified by "dbapasswd";
.4)开放管理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;