Modify the default encoding of mysql under ubuntu16.04.1, and Ubuntu 16.04.1mysql

Source: Internet
Author: User

Modify the default encoding of mysql under ubuntu16.04.1, and Ubuntu 16.04.1mysql

Configure Mysql character encoding in Ubuntu. After Mysql is installed, the default character encoding is latin1. The input is Chinese, but the output is a bunch of garbled characters. Now, you need to set the default character encoding of Mysql to support Chinese characters, such as GBK, GB23112, and so on.

 

Seriously speaking, the two mentally retarded mountains that I face from the Development of datiao programmers are coding and version problems. I feel uncomfortable and have no technical troubles.

Let's just talk about how to enable our teclon Go ~

 

First, find the mysql configuration file.

I will map it for my convenience. Sorry.

First, go to the directory where mysql stores configuration files.

Other installation methods can be found in your custom directory.

 

My. cnf is the configuration file.

 

Open my. cnf in a text file

 

This is what gedit looks like. After all, there is a Desktop linux, and there is a gedit that requires vi or vim.

 

If you do not have a graphic interface, please use the vi artifacts honestly.

 

View the mysql configuration file

Find the file referenced by this header file. The path is absolute.

 

Go to the mysql. conf. d file.

 

There are two configuration files in it. We need to modify mysqld. cnf. This is the basic configuration file of the mysql server, and it seems to be a security configuration file. No matter what it is, it has nothing to do with this purpose.

Use vi or gedit to view mysqld. cnf

Basic operations on vi

← H → L ↑ K ↓ j I insert (enter edit mode) esc exit edit mode: wq! Force exit and save (the command mode is the mode after esc). This is enough.

 

For more information about how to use labels for vi

 

This is not enough. We need to set the default encoding of the client.

 

 

Now, go to the mysql client configuration file directory.

Ls to see what is there

Mysql. cnf and mysqldump. cnf

We use vi or gedit to view mysql. cnf

In this way, the data encoding added by the client is utf8 by default.

 

Press esc key: wq! Save

The last sentence is to restart the mysql service.

 

Log on to mysql and use \ s to check whether the modification is successful.

 

This issue is here. If you have any mistakes, please note that

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.