如何通过mysql从命令行运行单个查询? [英] How do you run a single query through mysql from the command line?

查看:131
本文介绍了如何通过mysql从命令行运行单个查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够在脚本任务中在远程服务器上运行单个查询。



例如,直觉上,我会想象它会去例如:

  mysql -uroot -p -hslavedb.mydomain.com mydb_productionselect * from users; 


解决方案

 u< user> -p -eselect * from schema.table


I'm looking to be able to run a single query on a remote server in a scripted task.

For example, intuitively, I would imagine it would go something like:

mysql -uroot -p -hslavedb.mydomain.com mydb_production "select * from users;"

解决方案

mysql -u <user> -p -e "select * from schema.table"

这篇关于如何通过mysql从命令行运行单个查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆