* 更改客户端和服务器的默认编码:
1. 找到客户端配置[client] 在下面添加
default-character-set=utf8 默认字符集为utf8
2. 找到服务端配置[mysqld] 添加
default-character-set=utf8 默认字符集为utf8
对于MySQL 5.5版本以上,出现错误: [ERROR] /usr/local/mysql/bin/mysqld: unknown variable 'default-character-set=utf8', 应该改为 character-set-server = utf8
MySQL客户端:
查看编码: show Variables like '%set%';
+--------------------------+----------------------------------+
| Variable_name | Value |
+--------------------------+----------------------------------+
| auto_increment_offset | 1 |
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/local/mysql/share/charsets/ |
+--------------------------+----------------------------------+
设置编码: set names 'gbk';
// 导出数据库为指定编码的文件
mysqldump -u root --default-character-set=utf8 ebay_db>kingmart.sql
只导出数据结构:
mysqldump --opt -d -u root db_name>sql file
只导出数据不导出结构:
mysqldump -t -u root db_name>sql file
TODO
sudo mysqladmin shutdown
sudo mysqld_safe
mysqldump --default-character-set=latin1 --skip-set-charset -u root -p ebay_db>ebay_db_data.sql