Skip to content

Instantly share code, notes, and snippets.

@bugcy013
Forked from mrmichalis/hive-mysql-grants.sh
Created January 21, 2014 20:53
Show Gist options
  • Select an option

  • Save bugcy013/8548149 to your computer and use it in GitHub Desktop.

Select an option

Save bugcy013/8548149 to your computer and use it in GitHub Desktop.
for service in amon smon rman hmon nav hive; do
mysql -u root -e 'create database $service DEFAULT default character set utf8 collate utf8_general_ci;'
mysql -u root -e "grant all on $service.* TO '$service'@'localhost' IDENTIFIED BY 'password';"
mysql -u root -e "grant all on $service.* TO '$service'@'192-168-1-109.lunix.co' IDENTIFIED BY 'password';"
mysql -u root -e "grant all on $service.* TO '$service'@'%.lunix.co' IDENTIFIED BY 'password';"
done
mysql -u root -e 'show databases;'
#!/usr/bin/env bash
# http://www.cloudera.com/content/cloudera-content/cloudera-docs/CDH4/latest/CDH4-Installation-Guide/cdh4ig_topic_18_4.html
yum install -y expect
expect -c "
set timeout 10
spawn mysql_secure_installation
expect \"Enter current password for root (enter for none):\"
send \"$MYSQL\r\"
expect \"Change the root password?\"
send \"n\r\"
expect \"Remove anonymous users?\"
send \"y\r\"
expect \"Disallow root login remotely?\"
send \"y\r\"
expect \"Remove test database and access to it?\"
send \"y\r\"
expect \"Reload privilege tables now?\"
send \"y\r\"
expect eof
"
yum remove -y expect
wget http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.25.tar.gz/from/http://cdn.mysql.com/ -O /root/CDH/mysql-connector-java-5.1.25.tar.gz
cp mysql-connector-java-5.1.25/mysql-connector-java-5.1.25-bin.jar /opt/cloudera/parcels/CDH/lib/hive/lib/
for service in amon smon rman hmon nav hive; do
mysql -u root -e 'create database $service DEFAULT default character set utf8 collate utf8_general_ci;'
mysql -u root -e "grant all on $service.* TO '$service'@'localhost' IDENTIFIED BY 'password';"
mysql -u root -e "grant all on $service.* TO '$service'@'192-168-1-109.lunix.co' IDENTIFIED BY 'password';"
mysql -u root -e "grant all on $service.* TO '$service'@'%.lunix.co' IDENTIFIED BY 'password';"
done
mysql -u root -e 'show databases;'
# CREATE DATABASE metastore;
# USE metastore;
# SOURCE /opt/cloudera/parcels/CDH/lib/hive/scripts/metastore/upgrade/mysql/hive-schema-0.10.0.mysql.sql
# CREATE USER 'hive'@'192-168-1-220.lunix.co' IDENTIFIED BY 'password';
# REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'hive'@'192-168-1-220.lunix.co';
# GRANT SELECT,INSERT,UPDATE,DELETE,LOCK TABLES,EXECUTE ON metastore.* TO 'hive'@'192-168-1-220.lunix.co';
# FLUSH PRIVILEGES;
# quit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment