$sql="SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '数据库名称'"; $r=$pdo->query($sql,2); foreach($r as $v){ //if($v['TABLE_NAME']!='monxin_index_user'){continue;} 代码来源 梦行云软件 $sql="alter table `".$v['TABLE_NAME']."` convert to character set utf8"; if($pdo->exec($sql)){echo $sql.'';} }