Chinaunix首页 | 论坛 | 博客
  • 博客访问: 823977
  • 博文数量: 188
  • 博客积分: 4433
  • 博客等级: 上校
  • 技术积分: 1905
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-14 07:14
个人简介

linux

文章分类

全部博文(188)

文章存档

2016年(6)

2015年(22)

2014年(18)

2013年(5)

2012年(125)

2011年(10)

2010年(2)

分类: Mysql/postgreSQL

2012-01-03 11:38:57

1.管理命令
show variables  #查看各种系统参数,max_connections 等
show status     #查看数据库运行数据
 
2.常用sql

查整个库的状态:
select concat(truncate(sum(data_length)/1024/1024,2),'MB') as data_size
from information_schema.tables where TABLE_SCHEMA = 'runtime';
查单表:
select table_name,concat(truncate(sum(data_length)/1024/1024,2),'MB') as data_size
from information_schema.tables where TABLE_NAME = 'nagios_servicechecks';
 
备份恢复
mysqldump -uroot -pxxxx --all-databases >./xxxx.sql
source xxxx.sql
 
3.perl DBI
# connect
my $dbh = DBI->connect("DBI:mysql:database=db2;host=localhost", "joe", "guessme", {'RaiseError' => 1});
# execute INSERT query
my $rows = $dbh->do("INSERT INTO users (id, username, country) VALUES (4, 'jay', 'CZ')");
print "$rows row(s) affected ";
# execute SELECT query
my $sth = $dbh->prepare("SELECT username, country FROM users");
$sth->execute();
# iterate through resultset
# print values
while(my $ref = $sth->fetchrow_hashref()) {
    print "User: $ref-> ";
    print "Country: $ref-> ";
    print "---------- ";
}
# clean up
$dbh->disconnect();
阅读(905) | 评论(0) | 转发(0) |
0

上一篇:RRDtool绘图使用详细

下一篇:OTRS的教训

给主人留下些什么吧!~~