mysql基本操作
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了mysql基本操作,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1879字,纯文字阅读大概需要3分钟。
内容图文
![mysql基本操作](/upload/InfoBanner/zyjiaocheng/500/a11b25422ccd46f7aefd647ae214790d.jpg)
#访问控制
##登录mysql
mysql -u root -p
##查看所有用户
select user from mysql.user
##创建用户
CREATE USER ‘username‘@‘host‘ IDENTIFIED BY ‘password‘;
##删除用户
注意必须明确给出该账号的主机名
drop user ‘test‘@‘localhost‘;
##重命名用户
rename user ‘test‘@‘localhost‘to‘foo‘@‘localhost‘;
##修改密码
set password for ‘test‘@‘localhost‘=password(‘hello‘);
#权限管理
##查看权限
show grants for ‘test‘@‘localhost‘;
##授权
grant select(cust_id,cust_name) on mysql_test.customers to‘zhangsan‘@‘localhost‘;--授予在数据库mysql_test的表customers上拥有对列cust_id和列cust_name的select权限
grant select ,update on mysql_test.customers to ‘liming‘@‘localhost‘identified by‘123‘;--新建一个用户为liming,并授予其在数据库mysql_test的表customers上拥有select和update的权限
grant all on mysql_test.* to‘zhangsan‘@‘localhost‘;--授予可以在数据库mysql_test中执行所有操作的权限
grant create user on *.* to‘zhangsan‘@‘localhost‘;--授予系统中已存在用户zhangsan拥有创建用户的权限
##权限的转移
grant select,update on mysql_test.customers to‘zhou‘@‘localhost‘identified by‘123‘ with grant option;
如果上面with子句后面跟的是
max_queries_per_hour count、
max_updates_per_hour count、
max_connections_per_hour count、
max_user_connections count
中的某一项,则该grant语句可用于限制权限
grant delete on mysql_test.customers to ‘zhangsan‘@‘localhost‘ with max_queries_per_hour 1;--每小时只能处理一条delete语句的权限
##权限的撤销
revoke select on mysql_test.customers from‘zhangsan‘@‘localhost‘;--回收用户zhangsan在数据库mysql_test的表customers上的select权限
搬运自http://blog.csdn.net/ParanoidYang/article/details/61951265
mysql基本操作
标签:mysql sele connect 修改 highlight grant sql cal 授权
本文系统来源:https://www.cnblogs.com/littleby/p/8481439.html
内容总结
以上是互联网集市为您收集整理的mysql基本操作全部内容,希望文章能够帮你解决mysql基本操作所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。