Get the App
SLTechnology News&Howtos  ›  Database  › 

How to modify mysql Encoding to utf8

Shulou Source: shulou.com Published: 2022-05-31 11:07:20 10月29日 Update

This article introduces the relevant knowledge of "how to modify mysql code to utf8". In the operation process of actual cases, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!

How to modify mysql encoding to utf8: 1. Open and modify mysql configuration file "my.ini";2. Add "default-character-set = utf8" under "mysqld" label;3. Restart mysql service.

Operating environment of this tutorial: Windows 10 system, mysql version 8.0.22, Dell G3 computer.

How to modify mysql code to utf8

1. Edit MySql configuration file

MySql configuration file Windows generally in the system directory or MySql installation directory under the name my.ini, you can search, Linux is generally/etc/my.cnf

--Add the following under the [mysqld] label:

default-character-set = utf8character_set_server = utf8

Note: If something like "default-character-set=GBK" already exists under this label, just modify it.

--Add a line under the [mysql] tag

default-character-set = utf8

--Add a line under the [mysql.server] tag

default-character-set = utf8

--Add a line under the [mysqld_safe] label

default-character-set = utf8

--Add a line under the [client] label

default-character-set = utf8

Restart MySql service

Windows can be operated in Service Manager or from the command line:

net stop mysql Enter

net start mysql Enter

The service name may not necessarily be mysql, please press your own settings

Linux can be restarted with service mysql

If there is a startup failure, check the configuration file for setting errors

3. View the setting results

Login MySql Command Line Client: Open Command Line

mysql -uroot -p Enter

enter the password

After entering mysql, execute: show variables like "% character %";

In addition:

To create a database, you can use the following command:

create database app_relation character set utf8;use app_relation;source app_relation.sql;

The command to modify the database encoding is:

alter database app_relation character set utf8;"how to modify mysql encoding to utf8" content is introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!

Tags: Tags codes commands one line content files services configuration data databases more directories knowledge systems practical successful learning and then just you can make it in the Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Xiaomi Linux MariaDB vpn