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

How to solve the problem of Database garbled by linux

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

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!

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

Servers

Wechat

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

12
Report