Windows 1, MySQL is some environment variables can be set,
Can enter: show variables; you can view the current environment variable settings;
2, some of these variables are related to the setting of the character,
Can enter: Show variables Like´character%´;
3, which Character_set_results decided to return the results of the code,
Windows under the gb2312 can display the normal Chinese;
Set method: Set character_set_results=gb2312, and then enter;
4, of course, if you want to use the command Prompt line window to enter Chinese to modify the content of the database,
You can try setting set character_set_connection=gb2312;
and set character_set_client=gb2312;
Description
The value set above in the command Prompt line window.
Its validity is only valid for this connection,
After disconnecting from this connection,
Reconnect back in,
All of the variables you set are restored to the default values.
ubuntu9.0.4 MySQL garbled solution
Operating system Environment:
ubuntu9.0.4, MySql5.1 (via sudo apt-get install mysql5.1 installation)
Phenomenon:
In the terminal
1.mysql-uroot-proot into MySQL Client
2.use Parking Select a database
3.select *from users select a user table
The text segment inside shows as???
4. Use the statement show variables like ' character% '
It will show that there are several options for Latin, not UTF8
Solution steps: 1. Find the MySQL configuration file
The MySQL configuration file is/etc/init.d/mysql/my.cnf. (If not ubuntu9.0.4, this file does not necessarily exist, because you may take the MySQL installation method and the Internet is not the same, you will not be able to find/ETC/INIT.D/MYSQL/MY.CNF. Therefore, you need to use the Find command to locate the CNF file. Remember not to look for my.cnf because it does not necessarily exist, but should find *.cnf.
2. Cp/etc/init.d/mysql/my.cnf/etc/my.cnf.bak should be backed up before modification
Open MY.CNF Modify Encoding
# sudo vi/etc/init.d/mysql/my.cnf
Add under [mysqld]
Default-character-set=utf8
Add under [client]
Default-character-set=utf8
3. Restart MySQL
Depending on how you install MySQL, use the unused commands to reboot your MySQL. If you have configured to use the Mysqld self-boot method, you can perform
cd/usr/bin/
Mysqladmin-uroot-proot Shutdownmysqld_safe & (Execute sudo mysql_safe & if insufficient permissions)
4. Use the statement show variables like ' character% '
Then only one is Latin and the rest is UTF8.
Change Windows cmd (Dos) encoding to UTF-8
CHCP command,
Chcp 65001 is replaced by UTF-8 code page
Chcp 936 can be changed back to the default GBK
CHCP 437 is a U.S. English note: Personal test cmd under the modified code can not solve the MySQL garbled
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.