跳到主要內容

MySQL 亂碼設定

一、預設設定
xampp\mysql\bin\my.ini    
找到 [client] 區塊>
default-character-set=utf8
找到 [mysqld] 區塊>
character-set-server=utf8
collation-server=utf8_general_ci

二、修改已建table
ALTER TABLE tbl_name CONVERT TO CHARACTER SET utf8;
三、PDO連線時設定
$dbh = new PDO("mysql:$connstr",  $user, $password);
$dbh->exec("set names utf8");
四、meta時設定
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

留言