Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL dump file and commented out lines

Tags:

I have these lines at the top of a MySQL .sql file (dumped with phpMyAdmin):

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; 

But they all seem to be commented out. So will MySQL ignore them when the file is loaded back into a database? If so, why generate these lines at all?

like image 919
Spoonface Avatar asked Jul 15 '10 15:07

Spoonface


People also ask

How do I comment out a line in MySQL?

MySQL Server supports three comment styles: From a # character to the end of the line. From a -- sequence to the end of the line. In MySQL, the -- (double-dash) comment style requires the second dash to be followed by at least one whitespace or control character (such as a space, tab, newline, and so on).

What is Dumpfile in MySQL?

INTO DUMPFILE is a SELECT clause which writes the resultset into a single unformatted row, without any separators, in a file. The results will not be returned to the client. file_path can be an absolute path, or a relative path starting from the data directory.

Where does MySQL dump go?

It is at either at root or in current directory where you run the dump command. try this command on terminal.. hmm.. locate myBackup.


2 Answers

These are conditional comments aimed at certain versions of mySQL.

From here and here:

  • MySQL version specific comments start with /*!
  • And end with */
  • Version numbers are always 5 digits
  • Version numbers are in the format major release number, minor release number, revision number with the major being 1 digit and the minor and revision being 2 digits left-padded with 0’s
  • Version specific comments will target any version equal to or higher than the version number listed
like image 86
Unicron Avatar answered Oct 15 '22 01:10

Unicron


MySQL will parse and execute these lines of code, I believe for localization and character-encoding stuff, because the comments start with /*! (with the exclamation mark) instead of just the C-style /*.

Think of it the same way you do conditional comments and Internet Explorer. <!--[if IE]><![endif]--> looks like any plain old HTML comment to other browsers, but IE recognizes this special comment and parses it as needed. Likewise, /*! */ looks like any other comment to other SQL DBMSes but is special to MySQL.

like image 45
BoltClock Avatar answered Oct 15 '22 02:10

BoltClock