实例介绍命令行下向mysql添加新用户并分配权限
进入mysql的bin目录后
命令格式如下:
- bin>mysql -u root -p
回车后输入密码
命令格式
grant 权限1,权限2,...权限n on 数据库名称.表名称 to 用户名@用户地址 identified by '连接口令';
权限:
select,insert,update,delete,create,drop,index,alter,grant,references,reload,shutdown,process,file
如果允许全部权限,可以用all或者all privileges代替以上权限。
例如:
- mysql>grant select,insert,update,delete,create,drop on data1.table1 to austin@192.168.1.1 identified by '123';
给来自192.168.1.1的用户austin分配可对数据库data1的table1表进行select,insert,update,delete,create,drop等操作的权限,并设定口令为123。
- mysql>grant all privileges on data1.* to austin@192.168.1.1 identified by '123';
给来自192.168.1.1的用户austin分配可对数据库data1所有表进行所有操作的权限,并设定口令为123。
- mysql>grant all privileges on *.* to austin@192.168.1.1 identified by '123';
给来自192.168.1.1的用户austin分配可对所有数据库的所有表进行所有操作的权限,并设定口令为123。
- mysql>grant all privileges on *.* to austin@localhost identified by '123';
给本机用户austin分配可对所有数据库的所有表进行所有操作的权限,并设定口令为123。
- mysql>grant all privileges on *.* to austin@* identified by '123';
给任意连接过来的用户austin分配可对所有数据库的所有表进行所有操作的权限,并设定口令为123。(非必要时禁用,实在是太危险了。)
相关日志
读过这篇日志的读者同时也读了:
- 修改Microsoft SQL Server 排序规则的方法
- EVEmulator!EVE Online的服务端模拟器!
- 去结婚度蜜月的同事送了我一个东巴文的纪念品~
- 余~感谢您的来电~
- 天堂1游戏背景音乐下载和在线听!来自韩国天堂1官方网站
欢迎您的来访。喜欢这篇文章么? 发表一下您的看法 好让我们能交流交流一下, 或是 订阅这里的RSS,这样您可以及时获得最新文章。
Permalink:http://9npc.com/2007/09/mysql-add-newuser.htmlTrackback Address:http://9npc.com/2007/09/mysql-add-newuser.html/trackback








评论、Trackback、Pingback:
还没有评论。
发表评论