常用Mysql查询语句记录

1215阅读 0评论2009-01-08 kevinadmin
分类:Mysql/postgreSQL

常用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'

上一篇:Syslog-NG 日志服务器安装与配置
下一篇:Linux下面Chkconfig 命令+应用详解