< type="text/javascript">
document.body.oncopy = function() {
if (window.clipboardData) {
setTimeout(function() {
var text = clipboardData.getData("text");
if (text && text.length > 300) {
text = text + "\r\n\n本文来自CSDN博客,转载请标明出处:" + location.href;
clipboardData.setData("text", text);
}
}, 100);
}
}
修改my.ini文件
加上
default-character-set=gb2312
设定数据库字符集
alter database da_name default character set 'charset'
1)设置数据库编码 /etc/my.cnf
[mysqld]
default-character-set=gbk
...
[client]
default-character-set=gbk
---------------------------------------
2)按字符集导出
$mysqldump -u root -p dbname --default-character-set=gbk > a.sql;
3)查看SQL文件的编码
[root@localhost gethtml]# file a.sql
a.sql: UTF-8 Unicode ...
[root@localhost gethtml]# iconv -f utf-8 -t gbk a.sql > a2.sql
[root@localhost gethtml]# file a2.sql
a2.sql: Non-ISO extended-ASCII English text 这时已经是gbk的编码了
3)导入
查看数据库服务和客户端字符集
mysql> status;
Server characterset: gbk
Db characterset: gbk
Client characterset: latin1
Conn. characterset: latin1
mysql> set names 'gbk'; //这样
mysql> status;
Server characterset: gbk
Db characterset: gbk
Client characterset: gbk
Conn. characterset: gbk
这时才能导数据
mysql> s