Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1086903
  • 博文数量: 143
  • 博客积分: 969
  • 博客等级: 准尉
  • 技术积分: 1765
  • 用 户 组: 普通用户
  • 注册时间: 2011-07-30 12:09
文章分类

全部博文(143)

文章存档

2023年(4)

2021年(2)

2020年(4)

2019年(4)

2018年(33)

2017年(6)

2016年(13)

2014年(7)

2013年(23)

2012年(33)

2011年(14)

我的朋友

分类: LINUX

2019-01-23 20:03:27

一、新建用户
//登录Mysql
@>mysql -u root -p
@>密码
//创建用户
mysql> insert into mysql.user(Host,User,Password)
values('localhost','test',password('test123'));
//刷新系统权限表
mysql>flush privileges;
这样就创建了一个名为:test密码为:test123 的用户。

二、登录测试
mysql>exit;
@>mysql -u cplusplus -p
@>输入密码
mysql>登录成功

三、用户授权

//登录MYSQL
@>mysql -u root -p
@>密码
//首先为用户创建一个数据库(tz_ebank)
mysql>create database testdb;
//授权test用户使用密码test123拥有test数据库的所有权限,并从任何主机连接的话。
mysql >grant all privileges on testdb.* to test@'%' identified by 'test123' with grant obtion;  


---如果你想限制用户只能从192.168.1.222的主机连接到mysql服务器,以上的授权语句可做如下修改:
---mysql>grant all privileges on testdb.* to test@‘192.168.1.222’ identified by ‘test123';//刷新系统权限表
mysql>flush privileges;
mysql>其它操作

四、部分授权
mysql>grant select,update on testdb.* to test@localhost identified by ‘ test123';
//刷新系统权限表。
mysql>flush privileges;

五、删除用户
@>mysql -u root -p
@>密码
mysql>delete from user where user=‘test’;
mysql>flush privileges;


六、删除数据库

mysql>drop database test;

七、修改密码

@>mysql -u root -p
@>密码
mysql>update mysql.user set password=password(‘新密码’) where User='test' and Host='localhost';
mysql>flush privileges;
阅读(2950) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~