Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Making MySQL Executable Scripts.

DZone's Guide to

Making MySQL Executable Scripts.

·
Free Resource
Use "here document" statements to build complex script files with embedded SQL statements via the mysql utility.


#! /usr/bin/env bash

# execute some bash scripting commands here

mysql mydatabase <
  
   

Note that being in a bash script means that you can expand $-variables inside the SQL code directly.  This is, however, not advised unless you can be sure that only trusted, competent people will run your code.  Otherwise you'll be facing SQL injection attacks.
  
Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}