Is there a way I can access MySQL database using shell script? want to do some selects and some inserts on multiple tables?
It will be great if you can give some sample code as I am new to scripting.
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/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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With