0

I am very new to SQL and in fact just started yesterday. The book I am following is asking me to run sql statements from a text file they provided. However, I am getting an error message and I dont understand why. Here is the commands I entered along with the error message:

 mysql> use bank;
Database changed
mysql> source c:\sql\LearningSQLExample.sql;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id:    9
Current database: bank

--------------
mysql  Ver 14.14 Distrib 5.6.12, for Win64 (x86_64)

Connection id:          9
Current database:       bank
Current user:           lrngsql@localhost
SSL:                    Not in use
Using delimiter:        ;
Server version:         5.6.12 MySQL Community Server (GPL)
Protocol version:       10
Connection:             localhost via TCP/IP
Server characterset:    utf8
Db     characterset:    utf8
Client characterset:    cp850
Conn.  characterset:    cp850
TCP port:               3306
Uptime:                 1 day 4 hours 9 min 17 sec

Threads: 1  Questions: 6474  Slow queries: 1  Opens: 111  F
tables: 79  Queries per second avg: 0.063
--------------

ERROR:
Unknown command '\L'.
ERROR:
Failed to open file 'c:ql\LearningSQLExample.sql', error: 2

Thanks for your help.

2 Answers 2

1

You need to escape the backslash. Type source c:\\sql\\LearningSQLExample.sql;

Sign up to request clarification or add additional context in comments.

2 Comments

Its seems to have worked, but this is what was displayed: ERROR: Unknown command '\\'. And then a load of 'Query OK statements were displayed. Also, why is there a need for the \ escape character?
\s and \L will be interpreted as special characters. \s does exist while \L does not, hence the error. \\ converts to a single \
0

Just an additional solution when for newer version of mySQL command line Rename the LearningSQLExample.sql file to something that have underscore in it. Something like s_s.sql then at the command line try

source c:/temp/s_s.sql;

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.