0

i want to execute a mysql stored procedure from mysql command prompt in phpmyadmin.stored procedure is written in a file sample.sql. contents of sample.sql is:

DELIMITER //
create procedure sampleproc()
begin
declare x int;
set x=1;
while x<=1000 do
insert into dictionary (word,mean) values('a','a mean');
set x=x+1;
end while

end //

call sampleproc();

How can i run this using command line?

1 Answer 1

2

Using PHPMYADMIN

To create a stored procedure, you can use the following :

 DELIMITER //
    create procedure sampleproc()
    begin
    declare x int;
    set x=1;
    while x<=1000 do
    insert into dictionary (word,mean) values('a','a mean');
    set x=x+1;
    end while
    end//

And make sure you set the "Delimiter" field on the SQL tab to //.

Using Command Line

mysql --user=user_name --password=your_password db_name < sample.sql
Sign up to request clarification or add additional context in comments.

7 Comments

mysql --user=user_name --password=your_password db_name < sample.sql execute this command from windows/linux shell not from mysql command line
i have run it but error occurs like C:\>mysql --user=root --password=" " test < d:/sample.sql 'mysql' is not recognized as an internal or external command, operable program or batch file.
make sure mysql command is executable one. set the mysql path in environment variables or use abosulte path to mysql like c:\>F:\wamp\bin\mysql\mysql5.5.20\bin\mysql --user=root --password=" " test < d:/sample.sql
i didn't make it to work..i have set the path correct to /bin..and add the command..it shos that u have an error in sql syntax
try to remove this line "call sampleproc();" from sql file
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.