Set names UTF8;
Set names shows what character set is used in the SQL statement sent by the client. Therefore, the set NAMES ' cp1251 ' statement tells the server to use the character set cp1251 "for future messages from this client." It also specifies a character set for the result that the server sends back to the client. (For example, if you use a SELECT statement, it indicates what character set the column values use.) )
Here's how it works:
Mysql> Show variables like '%character% ';
+--------------------------+----------------------------------------------+
| variable_name | Value |
+--------------------------+----------------------------------------------+
| character_set_client | GBK |
| character_set_connection | GBK |
| Character_set_database | GBK |
| Character_set_filesystem | binary |
| Character_set_results | GBK |
| Character_set_server | GBK |
| Character_set_system | UTF8 |
| Character_sets_dir | /home/work/lamp/mysql5/share/mysql/charsets/|
+--------------------------+----------------------------------------------+
8 rows in Set (0.00 sec)
mysql> set names UTF8;
Query OK, 0 rows Affected (0.00 sec)
Mysql> SELECT * from Tbl_flowdis_limit 0,500;
+----+----------+-------+-----+--------------+
| id | domain | area | isp | node |
+----+----------+-------+-----+--------------+
| 1 | hiphotos | hubei | ct | Xian Telecom |
| 2 | 1111 | hubei | ct | Beijing Telecom |
| 3 | skycn | anhui | cnc | Beijing Unicom |
+----+----------+-------+-----+--------------+
3 rows in Set (0.00 sec)
Mysql>
Mysql> Show variables like '%character% ';
+--------------------------+----------------------------------------------+
| variable_name | Value |
+--------------------------+----------------------------------------------+
| character_set_client | UTF8 |
| character_set_connection | UTF8 |
| Character_set_database | GBK |
| Character_set_filesystem | binary |
| Character_set_results | UTF8 |
| Character_set_server | GBK |
| Character_set_system | UTF8 |
| Character_sets_dir | /home/work/lamp/mysql5/share/mysql/charsets/|
+--------------------------+----------------------------------------------+
8 rows in Set (0.00 sec)
MySQL client calls the remote host for MySQL