How to access mysql database using shell script?
try this
#!/bin/bash
echo "show all tables"
mysql -uroot -p'password' dbname<<EOFMYSQL
show tables;
EOFMYSQL
echo "Count of all records"
mysql -uroot -p'password' dbname<<EOFMYSQL
select count(*) from tbname;
EOFMYSQL
This link seems to have the information you want.
http://www.cyberciti.biz/faq/using-mysql-in-shell-scripts/
mysql -u user -p dbnane
You can use the mysql
command-line tool, from your shell-script.