1

My server OS is Red Hat 6 with MySQL. I'm using this line in a .sh file to run some jobs on the server:

mysql -u root -p[password] databasename < MySQL_JOBS_SENTENCES.txt

The content of the .txt file is:

call procedure1(date(now()));
call procedure2(date(now()));
call procedure3(current_Date());

Can I create or load a new stored procedure from a .txt file into my database the same way?

2

If you can execute SQL and you have sufficient privileges to create a stored procedure then you can create the stored procedure.

I'm assuming you can execute SQL with the .sh file above since you are currently using it to run jobs. Since it looks like you are using this to perform maintenance on a scheduled basis I am going to further assume that you want to update the database/deploy changes using the same mechanism. If this is true I would caution against this plan. While it might seem nice to automate a deployment at midnight while you're sleeping if anything goes wrong, you won't enjoy the fallout when your boss/customer/angry person X wakes you up because the world is on fire....

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.