MySQL Forums
Forum List  »  MySQL Shell

How can i execute an MySQL command through a shell script?
Posted by: Karan Doshi
Date: January 20, 2021 04:43AM

Hey guys,
I'm working on https://anankafasteners.com/ So for that, I want use MySQL command. So, How can I execute an SQL command through a shell script so that I can make it automated?

I want to restore data I have collected in a SQL file using a shell script. I want to connect to a server and restore data. The command works when executed separately via SSH command line.

This is the command I use:

mysql -h "server-name" -u root "password" "database-name" < "filename.sql"
This is the shell script code that creates the file ds_fbids.sql and pipes it into mysql.

perl fb_apps_frm_fb.pl
perl fb_new_spider.pl ds_fbids.txt ds_fbids.sql
mysql -h dbservername -u username -ppassword dbname < ds_fbids.sql

can anyone tell me the correct way to do this?

Options: ReplyQuote


Subject
Views
Written By
Posted
How can i execute an MySQL command through a shell script?
205
January 20, 2021 04:43AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.