Chinaunix首页 | 论坛 | 博客
  • 博客访问: 374969
  • 博文数量: 87
  • 博客积分: 2810
  • 博客等级: 少校
  • 技术积分: 825
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-28 22:34
文章分类

全部博文(87)

文章存档

2010年(25)

2009年(43)

2008年(19)

分类: Mysql/postgreSQL

2009-01-08 09:48:35

常用Mysql查询语句记录
一、授权
1.授权本地用户对所有数据库具有所有权限

mysql> grant all privileges on *.* to user@localhost identified by 'passwd';

2.授权本地用户对某个数据库具有所有权限

mysql> grant all privileges on database.* to user@localhost identified by 'passwd';

3.授权某个用户具有远程管理所有数据库权限,针对所有地址

mysql> grant all privileges on *database.* to 'user'@'%' identified by 'passwd';

4.授权某个用户在一个固定的IP对数据库具有所有权限

mysql> grant all privileges on *database.* to 'user'@'221.231.105.102' identified by 'passwd';


二、查询

1.查询所有

mysql> select * from DATABASE NAME

2.查询某个字段

mysql> select * from database where host='bac'

3.统计一个数据库表总共有多少条记录

mysql> select count(*) from database name;

4.统计一个表中的某个字段值有多少条记录

select COUNT(host) from syslog where host='server-4dv1dmee'

阅读(1152) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~