shell 操作mysql保存数据脚本 demo
来源:互联网 发布:亚洲人头大 知乎 编辑:程序博客网 时间:2024/06/13 09:35
在当前用户的home目录下新建文件 $HOME/.my.cnf 配置如下
[client]password = yourPwd
#!/bin/bashfunction readFileToSql(){ local imgArray=($(ls /myImages/ |grep -v cover |awk '{gsub(/\s/,"%20");print $0}' -)) local sqlTxt="\""; local MYSQL="mysql -uroot -hyourIp --default-character-set=utf8 -A -N" #这里面有两个参数,-A、-N,-A的含义是不去预读全部数据表信息,这样可以解决在数据表很多的时候卡死的问题 #-N,很简单,Don't write column names in results,获取的数据信息省去列名称 local i=0 ##删除数据 local delSql=`echo "truncate table databases.table ;"` $MYSQL -e "$delSql" ##插入数据 while [ $i -lt ${#imgArray[@]} ] do local title=${imgArray[$i]//.gif/""} local sql=`echo "INSERT INTO databases.table(title,cover_url,gif_url) VALUES($sqlTxt$title$sqlTxt,$sqlTxt$title.jpg$sqlTxt,$sqlTxt$title.gif$sqlTxt);"` #echo $sql $MYSQL -e "$sql" let i++ done echo "count:" $i}readFileToSql
阅读全文
1 0
- shell 操作mysql保存数据脚本 demo
- shell脚本操作mysql
- shell脚本操作mysql数据库
- linux shell脚本操作mysql
- shell脚本操作mysql数据库
- shell脚本操作mysql数据库
- shell脚本操作mysql数据库
- shell脚本操作mysql数据库
- shell脚本操作mysql数据库
- Shell脚本操作MySQL服务
- shell脚本操作mysql数据库
- SHELL脚本操作mysql数据库
- mysql服务操作shell脚本
- mysql数据迁移shell 脚本
- Shell脚本Demo
- shell脚本基础demo
- 使用shell脚本进行mysql操作
- 用shell脚本操作mysql数据库
- 手撸一个预加载页面,酷炫环形进度条
- Samba配置,实现windows远程访问
- HTTP学习
- 算法-->矩阵运算
- 第0002~0003题
- shell 操作mysql保存数据脚本 demo
- Linux内核并发机制
- 判断访问终端是否是微信浏览器
- linux一些常用服务的安装
- android 自定义属性使用
- ## 本地文件上传github (坚持看到尾部,提供各种命令行error,解决办法)##
- Android Studio 安装应用的时候提示Installation failed with message INSTALL_FAILED_USER_RESTRICTED
- 1120. Friend Numbers (20) <set>
- IdentityActivator()