How do you run a single query through mysql from the command line?

前端 未结 5 1933
旧巷少年郎
旧巷少年郎 2021-01-30 08:02

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:



        
5条回答
  •  死守一世寂寞
    2021-01-30 08:32

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

    From the usage printout:

    -e, --execute=name
    Execute command and quit. (Disables --force and history file)

提交回复
热议问题