In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
The following is about why Chinese garbled code appears in mysql under linux and how to solve it. The secret of the text lies in being close to the topic. So, no gossip, let's just read the following, I believe you will benefit from reading why Chinese garbled appears in mysql under linux and how to solve this article.
The default character set of the installed MySQL is latin1, and in order to change its character set to what the user needs (such as utf8), you must change its relevant configuration file.
Since 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 it 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/
Solution:
1. View the default character set
# mysql-u root-p # (enter password) mysql > show variables like 'character_set%'
2. Change the character set by modifying / 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. Otherwise, it will report: Starting MySQL...The server quit without updating PID file [failure] lib/mysql/localhost.localdomain.pid). Abnormal
3. Restart the MySQL CVM to make its settings take effect.
1. Startup mode 1, start with service: service mysqld start2, start with mysqld script: / etc/inint.d/mysqld start3, start with safe_mysqld: safe_mysqld& II, stop 1, start with service: service mysqld stop2, start with mysqld script: / etc/inint.d/mysqld stop3, mysqladmin shutdown 3, restart 1, start with service: service mysqld restart2, start with mysqld script: / etc/inint.d/mysqld restart
Is there anything you don't understand about why there are Chinese garbled codes in mysql under the above linux and how to solve the relevant content? Or if you want to know more about it, you can continue to follow our industry information section.
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.