bash - MySQL foreign_key_checks not staying disabled -


i have script (courtesy https://bash.cyberciti.biz):

#!/bin/bash muser="$1" mpass="$2" mdb="$3"  # detect paths mysql=$(which mysql) awk=$(which awk) grep=$(which grep)  if [ $# -ne 3 ]     echo "usage: $0 {mysql-user-name} {mysql-user-password} {mysql-database-name}"     echo "drops tables mysql"     exit 1 fi  tables=$($mysql -u $muser -p$mpass $mdb -e 'show tables' | $awk '{ print $1}' | $grep -v '^tables' )  t in $tables     $mysql -u $muser -p$mpass $mdb -e "set foreign_key_checks=0" ##aded myself in order disable foreign key checks"     echo "deleting $t table $mdb database..."     $mysql -u $muser -p$mpass $mdb -e "drop table $t" done 

i have 2 issues it:

  1. when running via curl remote machine fails errors like:

    xxx@xxx [~]# bash <(curl -s xxxxxxx.com/s/dbtruncate.sh) db_user db_pass db_name bash: /dev/fd/63: no such file or direct 

    when runnig via cli directly, works fine:

    xxx@xx [~/publichtml/s]# ./dbtruncate.sh db_user db_pass db_name warning: using password on command line interface can insecure. deleting batch table florinba_drp database... warning: using password on command line interface can insecure. deleting block_content table florinba_drp database... warning: using password on command line interface can insecure. deleting block_content_body table florinba_drp database... warning: using password on command line interface can insecure. deleting block_content_field_data table florinba_drp database... warning: using password on command line interface can insecure. deleting block_content_field_revision table florinba_drp database... 
  2. second issue despite having foreign key checks turned off every time, prior of deleting table in loop, still shows errors can due constraint:

    error 1217 (23000) @ line 1: cannot delete or update parent row: foreign key constraint fails error 1217 (23000) @ line 1: cannot delete or update parent row: foreign key constraint fails error 1217 (23000) @ line 1: cannot delete or update parent row: foreign key constraint fails 


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -