mysql配置管理平台_mysql的安装配置管理

mysql -u root -p

-u 选项用来指定登录的用户,后面的root表示采用root帐号登录。-p选项表示采用密码验证的方式登录。

在输入前面的命令后,系统会提示输入密码,如果正确的话就可以进入系统了。

3. 创建新用户

在大多数情况下,如果我们将结合mysql进行一些开发工作的话,不会直接采用root账户。一般root账户用来做一些系统管理和维护的工作,而且因为root权限太高。如果mysql系统出现问题容易导致所有数据的破坏。所以我们需要专门创建一个特定的用户,由root来给它指派一定的权限。这样,就算该账户出现问题,造成的损失也可能只是该帐号权限范围内的,不至于整体的破坏。

比如说我们要创建一个新的用户,并设置该用户的访问密码,在以root用户登录进入系统后,执行如下命令:

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

这样我们就添加了一个用户名为firesnow密码为1234的用户,但是这个账户目前还不能登陆,因为他没有任何权限。

删除用户

mysql>DELETE FROM mysql.user WHERE User="firesnow" and Host="localhost";

修改用户密码

mysql>update mysql.user set password=password('123456') where User="firesnow" and Host="localhost";

4. 配置新用户权限

配置用户权限我们要用到grant命令,他的格式可以简单概括为

grant 权限 on 数据库对象 to 用户@用户登陆地址

一、grant 普通数据用户,查询、插入、更新、删除 数据库中所有表数据的权利。

grant select on testdb.* to common_user@'%'

grant insert on testdb.* to common_user@'%'

grant update on testdb.* to common_user@'%'

grant delete on testdb.* to common_user@'%'

或者,用一条 MySQL 命令来替代:

grant select, insert, update, delete on testdb.* to common_user@'%'

二、grant 数据库开发人员,创建表、索引、视图、存储过程、函数。。。等权限。

grant 创建、修改、删除 MySQL 数据表结构权限。

grant create on testdb.* to developer@'192.168.0.%';

grant alter on testdb.* to developer@'192.168.0.%';

grant drop on testdb.* to developer@'192.168.0.%';

MySQLgrant 操作 MySQL 外键权限。

grant references on testdb.* to developer@'192.168.0.%';

grant 操作 MySQL 临时表权限。

grant create temporary tables on testdb.* to

grant 操作 MySQL 索引权限。

grant index on testdb.* to

grant 操作 MySQL 视图、查看视图源代码 权限。

grant create view on testdb.* to developer@'192.168.0.%';

grant show view on testdb.* to developer@'192.168.0.%';

grant 操作 MySQL 存储过程、函数 权限。

grant create routine on testdb.* to developer@'192.168.0.%'; -- now, can show procedure status

grant alter routine on testdb.* to developer@'192.168.0.%'; -- now, you can drop a procedure

grant execute on testdb.* to developer@'192.168.0.%';

三、grant 普通 DBA 管理某个 MySQL 数据库的权限。

grant all privileges on testdb to

其中,关键字 “privileges” 可以省略。

grant execute on procedure testdb.pr_add to 'dba'@'localhost'

grant execute on function testdb.fn_add to 'dba'@'localhost'

grant all on *.* to dba@'localhost'

四、MySQL grant 权限,分别可以作用在多个层次上。

1. grant 作用在整个 MySQL 服务器上: 可以查询 MySQL 中所有数据库中的表。

grant select on *.* to dba@localhost;

可以管理 MySQL 中的所有数据库

grant all on *.* to dba@localhost;

2. grant 作用在单个数据库上: 可以查询 testdb 中的表。

grant select on testdb.* to dba@localhost;

3. grant 作用在单个数据表上:

grant select, insert, update, delete on testdb.orders to

4. grant 作用在表中的列上:

grant select(id, se, rank) on testdb.apache_log to

5.MySQL grant 作用在存储过程、函数上:

grant execute on procedure testdb.pr_add to 'dba'@'localhost'

grant execute on function testdb.fn_add to 'dba'@'localhost'

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值