首页 > 代码库 > mysql 客户端调用 远程主机的mysql

mysql 客户端调用 远程主机的mysql

set names utf8;

SET NAMES显示客户端发送的SQL语句中使用什么字符集。因此,SET NAMES ‘cp1251‘语句告诉服务器将来从这个客户端传 来的信息采用字符集cp1251”。它还为服务器发送回客户端的结果指定了字符集。(例如,如果你使用一个SELECT语句,它表示列值使用了什么字符 集。)

下面看看效果:

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 | 西安电信 |
| 2 | 1111 | hubei | ct | 北京电信 |
| 3 | skycn | anhui | cnc | 北京联通 |
+----+----------+-------+-----+--------------+
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 客户端调用 远程主机的mysql