开发者

Running a stored procedure from crontab

开发者 https://www.devze.com 2023-02-18 07:01 出处:网络
I have the layout: Mys开发者_开发知识库ql DB DB name: db_name DB User name: user_name Password: 12345

I have the layout:

Mys开发者_开发知识库ql DB
DB name: db_name
DB User name: user_name
Password: 12345
Stored procedure: my_stored_procedure

How can I execute "my_stored_procedure" daily from a crontab?


Try to run something like this

mysql -h 'your ipadress' -u user_name –p'12345' mydatabase -e 'CALL my_stored_procedure()'

Just a guess i dont know if it will work.


I think better to use Events from mysql.

For more information please visit Using the Event Scheduler

Or use solution suggested by Michael.
Personally I like to execut mysql using -ss and socket file:

mysql -S/path_to_sock_file/mysql.sock -u user_name –p'12345' mydatabase -ss  -e 'CALL my_stored_procedure()'

-ss returns results as a plain text.

Cheers Arman.

0

精彩评论

暂无评论...
验证码 换一张
取 消