#!/bin/bash

USER="root"
PWD=$MYSQL_ROOT_PASSWORD
echo $PWD
#PWD="12345678"
DB=$MYSQL_DATABASE
TABLE="refGene"
ls /tulip/hg38
create_table=`cat /tulip/hg38/refGene.sql`
echo $USER" pwd "$PWD 

#DROP DATABASE  IF  EXISTS `$DB`;
mysql  -u $USER -p$PWD  <<EOF 2> /dev/null 
CREATE DATABASE IF NOT EXISTS $DB;
EOF

mysql  -u $USER -p$PWD  $DB <<EOF 2> /dev/null
$create_table
EOF

data_file="/tulip/hg38/refGene.txt"
load_sql="LOAD DATA  LOCAL INFILE '$data_file' IGNORE INTO TABLE $DB.$TABLE LINES TERMINATED by '\n'"
mysql -u $USER -p$PWD  $DB <<EOF 2> /dev/null
$load_sql
EOF
echo "Load data successfully!"
#echo $load_sql

#!/bin/bash

CURRENT_DIR=$(pwd)
FILE_DIR=$CURRENT_DIR/$(dirname $0)
USER="root"
MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:=example}
MYSQL_DATABASE=${MYSQL_DATABASE:=hg38}
TABLE="refGene"
ls $FILE_DIR/../hg38
HG38=$FILE_DIR/../hg38
CREATE_TABLE_SQL=`cat $HG38/refGene.sql`
#echo $CREATE_TABLE_SQL
echo "user:pass | $USER:$MYSQL_ROOT_PASSWORD" 

#DROP DATABASE  IF  EXISTS `$DB`;
mysql  -u $USER -p$MYSQL_ROOT_PASSWORD  <<EOF 2> /dev/null 
CREATE DATABASE IF NOT EXISTS $MYSQL_DATABASE;
EOF

mysql  -u $USER -p$MYSQL_ROOT_PASSWORD  --database hg38<<EOF 2> /dev/null 
$CREATE_TABLE_SQL
EOF

refGene_DATA_FILE=$HG38/refGene.txt
LOAD_refGene_DATA="LOAD DATA  LOCAL INFILE '$refGene_DATA_FILE' IGNORE INTO TABLE $MYSQL_DATABASE.$TABLE LINES TERMINATED by '\n'"
mysql  -u $USER -p$MYSQL_ROOT_PASSWORD  <<EOF 2> /dev/null 
$LOAD_refGene_DATA
EOF
echo "Load data successfully!"
#echo $load_sql

Add load refGene data tools
Add load refGene data tools
