How to access mysql database using shell script? How to access mysql database using shell script? database database

How to access mysql database using shell script?


This link seems to have the information you want.

http://www.cyberciti.biz/faq/using-mysql-in-shell-scripts/

mysql -u user -p dbnane


try this

#!/bin/bashecho "show all tables"mysql -uroot -p'password' dbname<<EOFMYSQLshow tables;EOFMYSQLecho "Count of all records"mysql -uroot -p'password' dbname<<EOFMYSQLselect count(*) from tbname;EOFMYSQL


You can use the mysql command-line tool, from your shell-script.