hue的历史查询记录querys乱码问题解决

hue的历史查询记录querys乱码问题解决:

hue的历史查询记录querys乱码问题解决

master1中配置文件/home/Hadoop/.versions/hue-3.10.0/desktop/conf/hue.ini

可以看到连接的是mysql数据库

[[database]]
#options='{"timeout": 60}'
host=localhost
port=3306
engine=mysql
user=hue
password=hue
name=hue

[hadoop@uhadoop-bwgkeu-master1 conf]$ ps -ef|grep mysql
root 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=mysql
mysql 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=3306
hadoop 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    = 3306
socket    = /var/lib/mysql/mysql.sock
default-character-set=utf8

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash
default-character-set=utf8

[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M

[mysqlhotcopy]
interactive-timeout

[mysqld]
port    = 3306
socket    = /var/lib/mysql/mysql.sock
skip-locking
key_buffer_size = 16K
max_allowed_packet = 1M
table_open_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 128K
server-id = 1
log-bin=mysql-bin
binlog_format=MIXED
binlog-do-db=hive
expire_logs_days=7
auto-increment-increment=2
auto-increment-offset=1
binlog-ignore-db = mysql
binlog-ignore-db = information_schema
default-character-set=utf8

[mysqld_safe]
default-character-set=utf8

如果报错mysql无法启动,则可以在mysqld部分替换成如下配置:

character-set-server=utf8

重启数据库service mysqld restart
可以看到编码都变成了utf8

mysql> 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服务,新建的查询就能正常显示了

hue的历史查询记录querys乱码问题解决

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/1653faeb07906bf314eb3fe0a9b1ca11.html