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

Three common ways to embed CSS in HTML documents

The following three methods are commonly used to d...

About the problem of writing plugins for mounting DOM in vue3

Compared with vue2, vue3 has an additional concep...

Teach you how to use Portainer to manage multiple Docker container environments

Table of contents Portainer manages multiple Dock...

Windows cannot start MySQL service and reports error 1067 solution

Suddenly when I logged into MySQL, it said that a...

Docker's flexible implementation of building a PHP environment

Use Docker to build a flexible online PHP environ...

MySQL database aggregate query and union query operations

Table of contents 1. Insert the queried results 2...

14 Ways to Create Website Content That Engages Your Visitors

When I surf the Net, I often see web sites filled...

Radio buttons and multiple-choice buttons are styled using images

I've seen people asking before, how to add sty...

Linux sftp command usage

Concept of SFTP sftp is the abbreviation of Secur...

What is Software 404 and 404 Error and what is the difference between them

First of all, what is 404 and soft 404? 404: Simpl...

Methods and problems encountered in installing mariadb in centos under mysql

Delete the previously installed mariadb 1. Use rp...

How to install JDK 13 in Linux environment using compressed package

What is JDK? Well, if you don't know this que...

Use jQuery to fix the invalid page anchor point problem under iframe

The application scenario is: the iframe page has n...

Summary of problems encountered in the implementation of Vue plug-ins

Table of contents Scene Introduction Plugin Imple...