[mdlug] Help with MariaDB and Bash scripting

Mathew May mathewmay72 at gmail.com
Wed Mar 16 12:53:19 EDT 2016


Hey guys,

I am trying to write a bash script that will my life a bit easier to
refresh database clusters in my lower environments.

Basic overview of the process is as follows:
set foreign_key_checks=0;
drop the database
create the database
set foreign_key_checks=1;
rsync .sql from remote location
import .sql file from local file system

rinse and repeat for each database

The problem I am having is in executing the setting the foreign_key_checks
via a bash script. I cannot even set the variable from the command line

Here is the line I have in my script:
$MYSQL -u root -p$DB_PASS -e "set foreign_key_checks = 0;"

$MYSQL = /usr/bin/mysql
$DP_PASS = password for my root user

After I run either the script (all steps except for set
foreign_key_checks=0; are commented out) or the command line command; I log
into the mariadb instance and run the following command:

show variables like '%foreign%';

And always the value is "on"

Is this parameter not able to be set from anywhere other then inside of
mysql?


More information about the mdlug mailing list