[mdlug] Help with MariaDB and Bash scripting

Mathew May mathewmay72 at gmail.com
Wed Mar 16 15:07:45 EDT 2016


Another way to get around the issue would be to issues "set global
foreign_key_checks=0" but them you also have to turn them back on.

A coworker brought that to my atteention as well.
On Mar 16, 2016 3:03 PM, "Carl T. Miller" <carl at carltm.com> wrote:

> Cool.  Glad to assist.  Now I just need to erase that
> mental image of nonstop searching and pounding!
>
> c
>
>
> Mathew May wrote:
> > Carl, you sir are my hero!!!  Session is exactly the issue.  I will have
> > to
> > chain commands in order to do the steps that need to be done while
> > foreign_key_checks=0.
> >
> > Days of google searching and pounding my head on the wall are over!
> >
> > On Wed, Mar 16, 2016 at 1:34 PM, Carl T. Miller <carl at carltm.com> wrote:
> >
> >> 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
> >> >
> >>
> >>
> >> _______________________________________________
> >> mdlug mailing list
> >> mdlug at mdlug.org
> >> http://mdlug.org/mailman/listinfo/mdlug
> >>
> > _______________________________________________
> > mdlug mailing list
> > mdlug at mdlug.org
> > http://mdlug.org/mailman/listinfo/mdlug
> >
>
>
> _______________________________________________
> mdlug mailing list
> mdlug at mdlug.org
> http://mdlug.org/mailman/listinfo/mdlug
>


More information about the mdlug mailing list