[mdlug] Help with MariaDB and Bash scripting

Carl T. Miller carl at carltm.com
Wed Mar 16 13:34:20 EDT 2016


I suspect that setting the foreign_key_checks only
survives within the current session.  Try this and
let me know the output.  If my theory is right, it
will be show 0 then 1.

$MYSQL -u root -p$DB_PASS -e "set foreign_key_checks = 0;
show variables like '%foreign%';"
$MYSQL -u root -p$DB_PASS -e "show variables like '%foreign%';"

c


Mathew May wrote:
> 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?
> _______________________________________________
> mdlug mailing list
> mdlug at mdlug.org
> http://mdlug.org/mailman/listinfo/mdlug
>




More information about the mdlug mailing list