Execute MySQL Stored Procedure using Command Line

2019-04-05 05:38发布

Please help me out to execute a MySQL Stored procedure in command line, where the procedure contains conditional statements..

4条回答
神经病院院长
2楼-- · 2019-04-05 05:40

Or:

mysql --user=your_username --execute="call stored_procedure_name()" db_name

The same as:

mysql ...  -e "call stored_procedure_name()" ...
查看更多
女痞
3楼-- · 2019-04-05 05:44

If you have parameters,

call stored_procedure_name(intValue, doubleValue, 'dateValue');

If your stored procedure doesnot take parameters,

call stored_procedure_name();
查看更多
迷人小祖宗
4楼-- · 2019-04-05 05:47
$ mysql --user=user_name --password=your_password db_name

mysql> call stored_procedure_name();

or

$ mysql --user=user_name --password=your_password db_name < script.sql

where script.sql contains your sql statement:

call stored_procedure_name();
查看更多
劳资没心,怎么记你
5楼-- · 2019-04-05 05:57

Or if you don't want to create a .sql file:

$ mysql -u your_username --password=your_password db_name <<!!
call stored_procedure_name();
!!
查看更多
登录 后发表回答