4

Here are my steps:
1. use bank(my database);
2. SOURCE d:\Nitro\testing\SQL\Books_mysql\Cookbook\recipes\tables\cow.sql

When I tried to source for a particular .sql file, namely 'cow.sql', the following error is displayed:

ERROR:
Failed to open file 'd:\Nitro\testing\SQL\Books_mysql\Cookbook\recipes\tables\cow.sql', error:2

content of "cow.sql": # Tables for online contruct-a-cow ordering scenario

DROP TABLE IF EXISTS cow_order;
#@ _CREATE_COW_ORDER_TABLE_
CREATE TABLE cow_order
(
 id          INT UNSIGNED NOT NULL AUTO_INCREMENT,
 # cow color, figurine size, and accessory items
 color VARCHAR(20),
 size ENUM('small','medium','large') DEFAULT 'medium',
 accessories SET('cow bell','horns','nose ring','tail ribbon')
              DEFAULT 'cow bell,horns',
 # customer name, street, city, and state (abbreviation)
 cust_name   VARCHAR(40),
 cust_street VARCHAR(40),
 cust_city   VARCHAR(40),
 cust_state  CHAR(2),
 PRIMARY KEY (id)
 );
 #@ _CREATE_COW_ORDER_TABLE_

 # Add some orders to the table

 INSERT INTO cow_order (color, size, accessories,
                   cust_name, cust_street, cust_city, cust_state)
 VALUES
 ('Black & White','large','cow bell,nose ring',
 'Farmer Brown','123 Elm St.','Bald Knob','AR');

 SELECT * FROM cow_order\G

 DROP TABLE IF EXISTS cow_color;
 #@ _CREATE_COW_COLOR_TABLE_
 CREATE TABLE cow_color (color CHAR(20));
 #@ _CREATE_COW_COLOR_TABLE_

 INSERT INTO cow_color (color)
 VALUES
 ('Black'),
 ('Brown'),
 ('Cream'),
 ('Black & White'),
 ('Red & White'),
 ('Red'),
 ('See-Through');

 SELECT * FROM cow_color;
1
  • 2
    can you post the contents of cow.sql? Commented Jul 7, 2015 at 8:58

3 Answers 3

6

You seem to be on Windows. Here you need to use forward slashes!

USE bank;

SOURCE D:/Nitro/testing/SQL/Books_mysql/Cookbook/recipes/tables/cow.sql;

Alternatively, you can use escaped back slashes:

SOURCE D:\\Nitro\\testing\\SQL\\Books_mysql\\Cookbook\\recipes\\tables\\cow.sql;
Sign up to request clarification or add additional context in comments.

6 Comments

you must not put quotes around the path. And the file must exist in the given location and it must be readable by the mysql process.
I haven't used any quotes and this file is normally read by mysql process while using such command as: mysql bank < d:\Nitro\testing\SQL\Books_mysql\Cookbook\recipes\tables\cow.sql.
It's done...it's my fault...d:\Nitro\тестирование\SQL\Books_mysql\Cookbook\recipes\tables\cow.sql I use this code, but with russian word this command doesn't work properly. When I use this d:\Nitro\testing\SQL\Books_mysql\Cookbook\recipes\tables\cow.sql and write russian word "тестирование" in English all has done correct. Thanks for helping!
I am glad it worked out. don't forget to vote up and accept the answer if your problem is fully solved.
Also, the source command MUST end in a semicolon, as shown above.
|
1

On Windows, use forward slash (/) in in path, and provide full path. For example:

source C:/wamp64/bin/mariadb/mariadb10.4.10/bin/goblissl_oc.sql

Comments

0

Also note that if there are spaces in the path, just leave them as spaces. No need to escape them. At least that applies on a Mac.

Comments

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.