How to set utf-8 encoding in mysql database

How to set utf-8 encoding in mysql database

Modify /etc/my.cnf or /etc/mysql/my.cnf file

[client]
default-character-set = utf8
[mysqld]
default-storage-engine = INNODB
character-set-server = utf8
collation-server = utf8_general_ci

Restart mysql and use the mysql client to check the encoding

show variables like '%char%';

Use UTF-8 encoding when creating a new database

create database 'test' default character set utf8 collate utf8_general_ci;

Create a table and create fields using UTF-8 encoding

create table test (
 'id' int(10) unsigned not null auto_increment,
 'name' varchar(50) character set utf8 default '',
 primary key('id')
 ) default charset=utf8;

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Why not use UTF-8 encoding in MySQL?
  • MySQL GBK → UTF-8 encoding conversion
  • Why is UTF-8 not recommended in MySQL?

<<:  CentOS 6-7 yum installation method of PHP (recommended)

>>:  Summary of methods to clear cache in Linux system

Recommend

How to use CSS media query aspect-ratio less

CSS media query has a very convenient aspect rati...

Detailed explanation of InnoDB storage files in MySQL

Physically speaking, an InnoDB table consists of ...

Detailed explanation of the role of the new operator in Js

Preface Js is the most commonly used code manipul...

How to use LibreOffice to convert document formats under CentOS

Project requirements require some preprocessing o...

IE8 browser will be fully compatible with Web page standards

<br />According to foreign media reports, in...

Code to enable IE8 in IE7 compatibility mode

The most popular tag is IE8 Browser vendors are sc...

SVG button example code based on CSS animation

The specific code is as follows: <a href="...

Introduction to the process of building your own FTP and SFTP servers

FTP and SFTP are widely used as file transfer pro...

JavaScript to achieve click image flip effect

I was recently working on a project about face co...

MySQL gets the current date and time function

Get the current date + time (date + time) functio...

Implementation of Docker cross-host network (manual)

1. Introduction to Macvlan Before the emergence o...

Details on using regular expressions in MySQL

Table of contents 1. Introduction 2. Prepare a pr...

How to use nginx to simulate canary release

This article introduces blue-green deployment and...

Detailed explanation of important cascading concepts in CSS

Recently, I encountered a problem in the process ...