How to Execute Query & Stored Procedure in Linux Using Shell Scripting.



How to Execute Query & Stored Procedure in Linux Using Shell Scripting.

You can simply use below mention script for executing the query or procedure.
#!/bin/sh
mysql -u root –ppassword -e 'call test_procedure();' Databasename

Where -p is used password in which you can mention the password of your mysql.
Where -e is used for executing the  query or stored procedure.
Where databasename is used for your mysql database name.

#!/bin/sh
mysql -u root –ppassword -e ‘select * from tbl_test;’ Databasename

 This single line can be used for  executing stored procedure as well as sql query.

You can save this script into any extension of file but you need to give the permission first
for executing the script file
for example:
#chmod +x filename

Comments