mysql dbi utf8乱码问题
2015-10-23 16:57
676 查看
<pre name="code" class="python">jrhdpt02:/root/sbin# cat t1.pl #!/usr/bin/perl use DBI; $user="root"; $passwd="xxxxx"; $dbh=""; $dbh = DBI->connect("dbi:mysql:database=zjzc;host=127.0.0.1;port=3306",$user,$passwd) or die "can't connect to database ". DBI-errstr; #$dbh->do("SET NAMES utf8"); $sth=$dbh->prepare("select sn,duration,name,maxUnit,addUnit,productType from zjzc.Product where sn in (263,121,122);"); $sth->execute; while (@recs=$sth->fetchrow_array) { foreach (@recs) {print "$_"} print "\n"; } $dbh->disconnect; jrhdpt02:/root/sbin# perl t1.pl 12123??-??30?250000011 12222????-????5170000100003 263180????-????2000000100003 jrhdpt02:/root/sbin# cat t1.pl #!/usr/bin/perl use DBI; $user="root"; $passwd="R00t,uHagt.0511"; $dbh=""; $dbh = DBI->connect("dbi:mysql:database=zjzc;host=127.0.0.1;port=3306",$user,$passwd) or die "can't connect to database ". DBI-errstr; $dbh->do("SET NAMES utf8"); $sth=$dbh->prepare("select sn,duration,name,maxUnit,addUnit,productType from zjzc.Product where sn in (263,121,122);"); $sth->execute; while (@recs=$sth->fetchrow_array) { foreach (@recs) {print "$_"} print "\n"; } $dbh->disconnect; jrhdpt02:/root/sbin# perl t1.pl 12123中均-至信30号250000011 12222中均尊享-贰拾壹号5170000100003 263180中均尊享-玖拾伍号2000000100003
相关文章推荐
- MySQL 函数 存储过程 操作
- mysql根据身份证信息来获取用户属性信息
- mysql去除内容中的换行和回车
- mysql+keepalived主从切换脚本 转
- mysql 基础
- mysql_connect(): Headers and client library minor version mismatch. Headers:
- mysql分表场景分析与简单分表操作
- mysql主从配置
- 性能调优案例分享:Mysql的cpu过高
- 理解MySQL——并行数据库与分区(Partition)
- mysql 索引
- 理解MySQL——复制(Replication)
- sql server与mysql数据库的链接
- 你容易忽视的mysql外键锁和自增锁
- mysql中order和limit问题,请教大家
- mysql的时间转化
- Mysql 演示示例存储过程
- Mysql中将日期转化为毫秒
- mysql 表的timestamp为自动添加
- windows 安装 mysql