一:
mysqlCMD="mysql -h${MYSQL_HOST} -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PASS}"
create_table_sql="CREATE TABLE IF NOT EXISTS ${MYSQL_DB_NAME}.${access_table_name} (
id INT(10) NOT NULL AUTO_INCREMENT,
accId INT(10) NOT NULL,
URL INT(10) NOT NULL,
....
PRIMARY KEY (id),
INDEX URL (URL)
)
COLLATE='utf8_general_ci'
ENGINE=MyISAM
ROW_FORMAT=DEFAULT
AUTO_INCREMENT=1" empty_table_sql="TRUNCATE ${MYSQL_DB_NAME}.${table_name} " echo $create_table_sql | ${mysqlCMD}
echo $empty_table_sql | ${mysqlCMD}
insert等操作同理
二:
loadsql="LOAD DATA LOW_PRIORITY LOCAL INFILE '${LOG_TEMP}' INTO TABLE ${MYSQL_DB_NAME}.${table_name} FIELDS TERMINATED BY '&' LINES TERMINATED BY '\n'(id,URL.....);" mysql -h ${MYSQL_HOST} -P ${MYSQL_PORT} -u ${MYSQL_USER} -p'${MYSQL_PASS}' -N -e "${loadsql}"
insert等操作同理