2021-05-12 14:32:11
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服務,新建的查詢就能正常顯示了
相關文章