


Reasons and solutions for Chinese garbled characters (Chinese question marks) in mysql under Linux
The default character set of installed MySQL is latin1. In order to change its character set to what the user needs (such as utf8), its related configuration files must be changed.
Since the default installation directory of MySQL under Linux is distributed in different files, it is not placed in the same directory like windows. You only need to modify the my.ini file, and it will take effect after restarting. So first let’s take a look at the database files, configuration files and command files of MySQL under Linux in different directories:
1. Database directory, the database files created are all in this directory
/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/
Solution:
1. View the default character set
#mysql -u root - p #(输入密码) mysql> show variables like 'character_set%';
2. Change the character set by modifying the /etc/my.cnf file
#/etc/my.cnf [client] default-character-set=utf8 [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 #default-character-set=utf8 character-set-server=utf8 init_connect='SET NAMES utf8' [mysql] no-auto-rehash default-character-set=utf8 [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid
Remember : added in mysqld It's character-set-server=utf8
instead of default-character-set=utf8
. Otherwise, it will report: Starting MySQL...The server quit without updating PID file [Failure]lib/mysql/localhost.localdomain.pid)
.Exception
3. Restart MySQL server to make its settings effective
一、启动方式 1、使用 service 启动:service mysqld start 2、使用 mysqld 脚本启动:/etc/inint.d/mysqld start 3、使用 safe_mysqld 启动:safe_mysqld& 二、停止 1、使用 service 启动:service mysqld stop 2、使用 mysqld 脚本启动:/etc/inint.d/mysqld stop 3、 mysqladmin shutdown 三、重启 1、 使用 service 启动:service mysqld restart 2、使用 mysqld 脚本启动:/etc/inint.d/mysqld restart
Recommended tutorial: Linux tutorial
The above is the detailed content of Reasons and solutions for Chinese garbled characters (Chinese question marks) in mysql under Linux. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Troubleshooting and solutions to the company's security software that causes some applications to not function properly. Many companies will deploy security software in order to ensure internal network security. ...

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

MySQL and phpMyAdmin are powerful database management tools. 1) MySQL is used to create databases and tables, and to execute DML and SQL queries. 2) phpMyAdmin provides an intuitive interface for database management, table structure management, data operations and user permission management.

In IntelliJ...

Safely handle functions and regular expressions in JSON In front-end development, JavaScript is often required...

How to solve the problem of printing spaces in IDEA console logs? When using IDEA for development, many developers may encounter a problem: the console printed...

In processing next-auth generated JWT...
