title: connect to mysql db and execute query and export result to variable - bash script
body: <p>I want to connect to mysql databse and execute some queries and export its result to a varibale, and do all of these need to be done entirely by bash script</p>
  
  <p>I have a snippet code but does not work.</p>
  
  <pre><code>#!/bin/bash
  
  BASEDIR=$(dirname $0)
  cd $BASEDIR
  
  mysqlUser=n_userdb
  mysqlPass=d2FVR0NA3
  mysqlDb=n_datadb
  
  result=$(mysql -u $mysqlUser -p$mysqlPass -D $mysqlDb -e "select * from confs limit 1")
  
  echo "${result}" &gt;&gt; a.txt
  </code></pre>
  
  <p>whats the problem ?</p>