Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the e flag and special characters do in mysql?

I am studying mysql from http://dev.mysql.com/doc/refman/5.7/en/batch-mode.html . On second paragraph it says:

If you are running mysql under Windows and have some special characters in the file that cause problems, you can do this:

C:\> mysql -e "source batch-file"
  • What are special characters? If I save a file in notepad, would there be automatic special characters saved in the file? How to know whether they are there or not? Are they hidden?

  • What would the -e flag do? Where can I find its explanation in mysql documentation?

like image 527
user31782 Avatar asked Sep 07 '25 15:09

user31782


1 Answers

-e is actually short for --execute, that's probably why you had trouble finding it. http://dev.mysql.com/doc/refman/5.7/en/mysql-command-options.html#option_mysql_execute

Execute the statement and quit. The default output format is like that produced with --batch. See Section 5.2.4, “Using Options on the Command Line”, for some examples. With this option, mysql does not use the history file.

A special charater is something that needs to be escaped in an SQL query. You will know when you run into them because mysql will produce errors.

like image 185
e4c5 Avatar answered Sep 10 '25 03:09

e4c5