Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Why set ubuntu16.04 to encode mysql as utf8

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces why the ubuntu16.04 set mysql code as utf8, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

After ubuntu 16.04mysql is installed, the default code of the database is not all utf8, and some of them are latin1, which leads to garbled codes when storing Chinese in the database, so it is necessary to set the default code of the following database. Usually, one way to modify the encoding is to modify it directly in the interactive shell of mysql, but this modification is not permanent. If you exit the interactive shell, it will become invalid. The blogger mainly describes how to permanently modify the default encoding of the mysql database.

Steps

First, you can log in to mysql's interactive shell and enter the following command to see how the current database is encoded.

Show variables like'% character%'

As can be seen from the above, after the mysql database is installed, it is not always utf8 at the beginning.

Exit the interactive shell and modify the following configuration file

Enter the following command to open the first configuration file

Sudo vim / etc/mysql/conf.d/mysql.cnf

Add the following configuration on the next line of the [mysql] tag

Default-character-set=utf8

Enter the following command to open the second configuration file

Sudo vim / etc/mysql/mysql.conf.d/mysqld.cnf

Locate the [mysqld] tag and add the following configuration on its next line

Character-set-server=utf8

After the configuration file has been successfully modified, type the following command to restart the mysql service

Sudo service mysql restart

Check the default encoding of the database after reboot

Show variables like'% character%'

OK, configuration complete

Thank you for reading this article carefully. I hope the article "Why set ubuntu16.04 to code mysql as utf8" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report