Home > Database > Mysql Tutorial > body text

How to Change the Default Character Set of a MySQL Table from `latin1` to `utf8`?

Linda Hamilton
Release: 2024-10-30 05:55:02
Original
884 people have browsed it

How to Change the Default Character Set of a MySQL Table from `latin1` to `utf8`?

Altering the Default Character Set of a MySQL Table

When working with tables in MySQL, it is essential to consider the character set used for storing data. By default, tables are created with the 'latin1' character set, but this may not be suitable for certain scenarios. This article will delve into how to modify the default character set of a MySQL table from 'latin1' to 'utf8'.

Problem:

You have a MySQL table named 'etape_prospection' that is currently using the 'latin1' character set. You wish to change the default character set to 'utf8' to accommodate non-Latin characters.

Solution:

To alter the default character set and all character columns of a table to a new character set, use the following syntax:

ALTER TABLE table_name CONVERT TO CHARACTER SET charset_name;
Copy after login

In this case, the table name is 'etape_prospection' and the desired character set is 'utf8'. The updated query will be:

ALTER TABLE etape_prospection CONVERT TO CHARACTER SET utf8;
Copy after login

By executing this query, the character set of the 'etape_prospection' table, including its character columns, will be modified to 'utf8'.

The above is the detailed content of How to Change the Default Character Set of a MySQL Table from `latin1` to `utf8`?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!