hue的历史查询记录querys乱码问题解决:
master1中配置文件/home/hadoop/.versions/hue-3.10.0/desktop/conf/hue.ini可以看到连接的是mysql数据库
[[database]]#options='{"timeout": 60}'host=localhostport=3306engine=mysqluser=huepassword=huename=hue
[hadoop@uhadoop-bwgkeu-master1 conf]$ ps -ef|grep mysqlroot 7211 1 0 Jun28 ? 00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --pid-file=/var/run/mysqld/mysqld.pid --basedir=/usr --user=mysqlmysql 7358 7211 0 Jun28 ? 01:13:12 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --log-error=/var/lib/mysql/uhadoop-bwgkeu-master1.err --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock --port=3306hadoop 27302 17671 0 14:23 pts/0 00:00:00 grep mysql
分析:在hue的库desktop_document表中可以看到中文是正常的,查到页面中就乱码了,可能是在查询中某个字段出现问题了
终极解决办法:
1.修改/etc/my.cnf配置修改clent,mysqld,mysql,mysql_safe部分都添加default-character-set=utf8[client]port = 3306socket = /var/lib/mysql/mysql.sockdefault-character-set=utf8[mysqldump]quickmax_allowed_packet = 16M[mysql]no-auto-rehashdefault-character-set=utf8[myisamchk]key_buffer_size = 8Msort_buffer_size = 8M[mysqlhotcopy]interactive-timeout[mysqld]port = 3306socket = /var/lib/mysql/mysql.sockskip-lockingkey_buffer_size = 16Kmax_allowed_packet = 1Mtable_open_cache = 4sort_buffer_size = 64Kread_buffer_size = 256Kread_rnd_buffer_size = 256Knet_buffer_length = 2Kthread_stack = 128Kserver-id = 1log-bin=mysql-binbinlog_format=MIXEDbinlog-do-db=hiveexpire_logs_days=7auto-increment-increment=2auto-increment-offset=1binlog-ignore-db = mysqlbinlog-ignore-db = information_schemadefault-character-set=utf8[mysqld_safe]default-character-set=utf8
如果报错mysql无法启动,则可以在mysqld部分替换成如下配置:
character-set-server=utf8
重启数据库service mysqld restart
可以看到编码都变成了utf8mysql> show variables like '%char%';+--------------------------+----------------------------+| Variable_name | Value |+--------------------------+----------------------------+| character_set_client | utf8 || character_set_connection | utf8 || character_set_database | utf8 || character_set_filesystem | binary || character_set_results | utf8 || character_set_server | utf8 || character_set_system | utf8 || character_sets_dir | /usr/share/mysql/charsets/ |+--------------------------+----------------------------+8 rows in set (0.00 sec)
2.将hue库导出,然后修改hue的库编码(默认是latin1)和所有表所有字段的编码
mysql> show create database hue;+----------+--------------------------------------------------------------+| Database | Create Database |+----------+--------------------------------------------------------------+| hue | CREATE DATABASE `hue` /*!40100 DEFAULT CHARACTER SET utf8 */ |
3.再次将数据库导入,重启hue服务,新建的查询就能正常显示了