black black - 2 months ago 8
MySQL Question

mysql server 5.0 command line client failed to open file .sql

I am trying to use mysql command line client to execute a procedure. The procedure

helloworld()
is executing fine in mysql query browser.

db scheme selected in query browser

DELIMITER $$
DROP PROCEDURE IF EXISTS helloworld$$
CREATE PROCEDURE helloworld()
BEGIN
SELECT 'helloworld';
END$$


When I
call helloworld()
it returns helloworld. I am saving the procedure as
helloworld.sql
saved in SQL SCRIPT FILE ANSI .sql in desktop

Now I am trying to access the .sql file saved in desktop from cmd client giving the password that connects successfully

Now when I type

ENTER PASSWORD:******
Your Mysql connection id is 43
Server Vesion 5.5.24

mysql> SOURCE helloworld.sql
ERROR failed to open file helloworld.sql Error 2


Should I give the path of the file?

Answer

Try:

/path/to/file/helloworld.sql:

USE `yourdb`;

DELIMITER $$

DROP PROCEDURE IF EXISTS `helloworld`$$

CREATE PROCEDURE `helloworld`()
BEGIN
  SELECT 'helloworld';
END$$

DELIMITER ;

Then from the command line try:

Your Mysql connection id is 43
Server Vesion 5.5.24

mysql> SOURCE /path/to/file/helloworld.sql
Comments