Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to solve the problem of Database garbled by linux

Shulou Source: shulou.com Published: 2022-06-03 03:05:50 10月22日 Update

The default character set of the installed MySQL is latin1. In order to change its character set to what the user needs (such as utf8), you must change its relevant configuration file. Because the default installation directory of MySQL under linux is distributed in different files; unlike windows, you only need to modify the my.ini file in the same directory and take effect after restart. So let's first take a look at the database files, configuration files and command files of MySQL under linux in different directories:

1. Database directory, where all the database files created are located.

/ var/lib/mysql/

2. Configuration file (location of mysql.server command and configuration file)

/ usr/share/mysql

3. Related commands (such as mysql mysqladmin, etc.)

/ usr/bin

4. Startup script (such as mysql startup command)

/ etc/rc.d/init.d/

View the default character set

# mysql-u root-p # (enter password) mysql > show variables like 'character_set%'

Modify character set modify / etc/my.cnf file

# / etc/my.cnf [client] default-character-set=utf8 [mysqld] datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sockuser=mysql# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0#default-character-set=utf8character-set-server=utf8init_connect='SET NAMES utf8' [mysql] no-auto-rehashdefault-character-set=utf8 [mysqld_safe] log-error=/var/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pid

Remember: it is character-set-server=utf8, not default-character-set=utf8, that is added to mysqld.

These are the details of the solution to garbled code in linux database. Please pay more attention to other related articles!

Tags: Files directories data databases commands characters character sets configurations different garbled content just password is location location article method more user Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Xiaomi Linux vpn Huawei