Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In MySQL, what does this mean? /*!40100 DEFAULT CHARACTER SET latin1 */

Tags:

mysql

 /*!40100 DEFAULT CHARACTER SET latin1 */
  1. Why is it between comment marks?

  2. What is the 40100 all about?

  3. What is the ! for?

  4. What does it do?

  5. Where is the documentation for this?

like image 708
Tom Haws Avatar asked Feb 15 '12 17:02

Tom Haws


People also ask

What is default character set in MySQL?

The default MySQL server character set and collation are latin1 and latin1_swedish_ci , but you can specify character sets at the server, database, table, column, and string literal levels.

What is charset latin1 in MySQL?

The MySQL latin1 character set is such a one-byte character set for Western Europe, and it is the default character set of MySQL up to and including 5.7. In spite of the name, the character set is actually Windows-1252 compliant, which is a superset of ISO-8859-1, also known as Latin-1.

How do I change the default character set in MySQL?

The MySQL server has a compiled-in default character set and collation. To change these defaults, use the --character-set-server and --collation-server options when you start the server.

How do I change MySQL encoding to UTF 8?

To change the character set encoding to UTF-8 for the database itself, type the following command at the mysql> prompt. Replace dbname with the database name: Copy ALTER DATABASE dbname CHARACTER SET utf8 COLLATE utf8_general_ci; To exit the mysql program, type \q at the mysql> prompt.


1 Answers

  1. It's a conditional comment that can be interpreted by MySQL

  2. The code 40100 means only these versions of MySQL>=4.1.0 (4.01.00) will interpret the conditional comment.

  3. The ! is here to force MySQL to parse the code between the /* ... */

  4. It sets the value of the parameter DEFAULT CHARACTER = 'latin1' so that the data in an SQL dump can be intepreted correctly during import. It doesn't affect the database structure, but merely helps the export/import process to work right.

  5. http://dev.mysql.com/doc/refman/4.1/en/comments.html

like image 50
adrien54 Avatar answered Oct 01 '22 18:10

adrien54