shell脚本中操作mysql
1, mysql -e
select_sql="select count(distinct id) from tb_test"
num=$(mysql -s -h$host -u$user -p$passwd $dbname -e "$register_sql")
-s参数的使用是减少查询字段的输出
2, mysqldump导出mysql数据
#!/bin/bash #变量定义 host="127.0.0.1" user="root" passwd="123456" dbname="test" tablename="tb_test" mysqldump -u$user -p$passwd -h$host $dbname $tablename --where "id > 1 and id < 1000" > 1.sql
3, mysql直接登陆数据库
#!/bin/bash user="user" passwd="password" host="192.168.0.1" mysql -h$host -u$user -p$passwd db
相关推荐
tufeiax 2020-09-03
huha 2020-10-16
laisean 2020-11-11
大牛牛 2020-10-30
firefaith 2020-10-30
liguojia 2020-10-20
wangzhaotongalex 2020-10-20
以梦为马不负韶华 2020-10-20
JohnYork 2020-10-16
Julyth 2020-10-16
applecarelte 2020-10-16
laisean 2020-09-27
flycappuccino 2020-09-27
liguojia 2020-09-27
wangzhaotongalex 2020-09-22
流年浅滩 2020-10-23
liujianhua 2020-10-22
woaimeinuo 2020-10-21
laisean 2020-09-01
vvu 2020-09-16
libao 2020-09-16
Yyqingmofeige 2020-08-18
zhushixia 2020-08-17