2017年2月27日月曜日

HiveのSelect文に、ヘッダー行を出せる用法

デフォルトのselectを実行したら、ヘッダーなしの結果が出力されます。
どんなカラムなのかを知りたいときがあります。
ヘッダカラムを出力される方法は、select文を実行する前に、
以下を追加します。

set hive.cli.print.header=true;
使い方例:
hive -e "set hive.cli.print.header=true; select * from user ;"

2017年2月26日日曜日

mysql テーブルロード時に、「The used command is not allowed with this MySQL version」エラーの問題

前日、新しいデータベースにデータをロードしようと思ったら、以下のエラーになりました。
mysql -u root -p -h 192.168.1.1 user -e"LOAD DATA LOCAL INFILE '/tmp/use.tsv' INTO TABLE user;"
Enter password:
ERROR 1148 (42000) at line 1: The used command is not allowed with this MySQL version


解決方法としては、「--local-infile=1」をつけて再実行することです。
mysql --local-infile=1 -u root -p -h 192.168.1.1 user -e"LOAD DATA LOCAL INFILE '/tmp/use.tsv' INTO TABLE user;"
Enter password:
「--local-infile=1」オプションを指定することによって、LOAD DATA LOCALを有効にします。逆に、「--local-infile=0」オプションを指定したらLOAD DATA LOCALを無効にします。


2017年1月18日水曜日

mysql 5.6でgrantをしたら、ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tm p/mysql_q4m.sock' のエラー

解決方法は、以下のコマンドを実行
# mysql_upgrade -u root -p

Looking for 'mysql' as: /usr/local/q4m/bin/mysql
Looking for 'mysqlcheck' as: /usr/local/q4m/bin/mysqlcheck
Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/tmp/mysql_q4m.sock'
Warning: Using a password on the command line interface can be insecure.
Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/tmp/mysql_q4m.sock'
Warning: Using a password on the command line interface can be insecure.
mysql.columns_priv                                 OK
mysql.db                                           OK
mysql.event                                        OK
mysql.func                                         OK
mysql.general_log                                  OK
mysql.help_category                                OK
mysql.help_keyword                                 OK
mysql.help_relation                                OK
mysql.help_topic                                   OK
mysql.host                                         OK
mysql.ndb_binlog_index                             OK
mysql.plugin                                       OK
mysql.proc                                         OK
mysql.procs_priv                                   OK
mysql.servers                                      OK
mysql.slow_log                                     OK
mysql.tables_priv                                  OK
mysql.time_zone                                    OK
mysql.time_zone_leap_second                        OK
mysql.time_zone_name                               OK
mysql.time_zone_transition                         OK
mysql.time_zone_transition_type                    OK
mysql.user                                         OK
Running 'mysql_fix_privilege_tables'...
Warning: Using a password on the command line interface can be insecure.
Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/tmp/mysql_q4m.sock'
Warning: Using a password on the command line interface can be insecure.
Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/tmp/mysql_q4m.sock'
Warning: Using a password on the command line interface can be insecure.
freegame_queue.application_message_merge           OK
freegame_queue.game_playing_date                   OK
freegame_queue.guide_send_twitter_dm               OK
freegame_queue.mailbatch_mail                      OK
freegame_queue.messageapi_application_mail         OK
freegame_queue.messageapi_user_mail                OK
OK
Could not create the upgrade info file '/usr/local/q4m/var/mysql_upgrade_info' in the MySQL Servers datadir, errno: 13
[vagrant@010node mysql5.6q4m]$ sudo /usr/local/q4m/bin/mysql_upgrade -u root -p
Enter password:
Looking for 'mysql' as: /usr/local/q4m/bin/mysql
Looking for 'mysqlcheck' as: /usr/local/q4m/bin/mysqlcheck
Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/tmp/mysql_q4m.sock'
Warning: Using a password on the command line interface can be insecure.
Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/tmp/mysql_q4m.sock'
Warning: Using a password on the command line interface can be insecure.
mysql.columns_priv                                 OK
mysql.db                                           OK
mysql.event                                        OK
mysql.func                                         OK
mysql.general_log                                  OK
mysql.help_category                                OK
mysql.help_keyword                                 OK
mysql.help_relation                                OK
mysql.help_topic                                   OK
mysql.host                                         OK
mysql.ndb_binlog_index                             OK
mysql.plugin                                       OK
mysql.proc                                         OK
mysql.procs_priv                                   OK
mysql.proxies_priv                                 OK
mysql.servers                                      OK
mysql.slave_master_info                            OK
mysql.slave_relay_log_info                         OK
mysql.slave_worker_info                            OK
mysql.slow_log                                     OK
mysql.tables_priv                                  OK
mysql.time_zone                                    OK
mysql.time_zone_leap_second                        OK
mysql.time_zone_name                               OK
mysql.time_zone_transition                         OK
mysql.time_zone_transition_type                    OK
mysql.user                                         OK
Running 'mysql_fix_privilege_tables'...
Warning: Using a password on the command line interface can be insecure.
Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/tmp/mysql_q4m.sock'
Warning: Using a password on the command line interface can be insecure.
Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/tmp/mysql_q4m.sock'
Warning: Using a password on the command line interface can be insecure.
freegame_queue.application_message_merge           OK
freegame_queue.game_playing_date                   OK
freegame_queue.guide_send_twitter_dm               OK
freegame_queue.mailbatch_mail                      OK
freegame_queue.messageapi_application_mail         OK
freegame_queue.messageapi_user_mail                OK
OK
[vagrant@010node mysql5.6q4m]$ /usr/local/q4m/bin/mysql -h localhost -P 13306 -u"root" -p"vagrant"
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 18
Server version: 5.6.32-q4m-log Q4M

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.