shell连接MySQL

前端之家收集整理的这篇文章主要介绍了shell连接MySQL前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1.连接MysqL进入命令行模式

vim MysqL_douguo_data.sh

#!/bin/sh
/usr/local/MysqL/bin/MysqL -u hadooper -h192.168.1.131 douguo_data -p"hadoopaaa";

2.连接MysqL执行sql获取数据

# query languages
QUERYA="select concat_ws(',',concat_ws('',id,subject),right(send_time,5)) from dd_sys_mail_set where send_type='day';"

# query from MysqL
count_a=`/usr/local/MysqL/bin/MysqL -h${HOSTNAME} -u${USERNAME} -p${PASSWORD} -D ${DBNAME} -e "${QUERYA}" --skip-column-name`


# echo in data files and delete the first line 'log in file /var/MysqL/query.log'
echo "${count_a}" | sed 's/\t/,/g' > ${_WORK_DIR}/tmp/queryloga.log
原文链接:https://www.f2er.com/bash/388942.html

猜你在找的Bash相关文章