Linux MySQL change character set encoding and Ubuntu under change MySQL default encoding

Source: Internet
Author: User
Tags mysql tutorial

Linux MySQL Tutorial change character set encoding and Ubuntu under change MySQL default encoding

Find configuration file
/etc/mysql/my.cnf
Under [client], add
Default-character-set=utf8
Add under [mysqld]
Default-character-set=utf8
Reboot the server
Service MySQL Restart
Type a command in MySQL:
Show variables like ' character_set_% '
The results appear as follows:
Character_set_client UTF8
Character_set_connection UTF8
Character_set_database latin1
Character_set_filesystem binary
Character_set_results UTF8

Ubuntu under change MySQL default encoding (character set)


installing MySQL
sudo apt-get install mysql-server #直接自动获得可用版本
You can also write this
sudo apt-get install mysql-server-5.0 #安装mysql服务器5.0 version
After installation
/etc/init.d/mysql Start (stop) starts and stops the server
/etc/mysql/main configuration file location my.cnf
/var/lib/mysql/placed is the Database Tutorial table folder, where MySQL is equivalent to Windows MySQL under the Date folder
After you start MySQL, log in to MySQL with Root
isher@isher-ubuntu:~$ Mysql-u Root
>show variables like ' character% '; #执行编码显示
+--------------------------+----------------------------+
| variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | Latin1 |
| character_set_connection | Latin1 |
| Character_set_database | Latin1 |
| Character_set_filesystem | binary |
| Character_set_results | Latin1 |
| Character_set_server | Latin1 |
| Character_set_system | UTF8 |
| Character_sets_dir | /usr/share/mysql/charsets/|
+--------------------------+----------------------------+
At some point, we continue to modify the MySQL default database encoding to ensure that some of the migrated programs can be displayed correctly, edit the my.cnf file for coding changes, Windows can be directly with the MySQL Server Instance Config Wizard to set
Modify 3 my.cnf 1/etc/mysql/my.cnf files under Linux
Locate the client configuration [clients] add below
Default-character-set=utf8 default character set is UTF8
After finding [mysqld] Add
Default-character-set=utf8 default character set is UTF8
init_connect= ' Set NAMES UTF8 ' (set to connect to MySQL database with UTF8 encoding to make MySQL database run UTF8)
After the modification, restart the MySQL can, query show variables like ' character% ';
+--------------------------+----------------------------+
| variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | UTF8 |
| character_set_connection | UTF8 |
| Character_set_database | UTF8 |
| Character_set_filesystem | binary |
| Character_set_results | UTF8 |
| Character_set_server | UTF8 |
| Character_set_system | UTF8 |
| Character_sets_dir | /usr/share/mysql/charsets/|
+--------------------------+----------------------------+
This method is also valid for standard MySQL versions, and for/etc/my.cnf files, you need to my-large.cnf from Mysql/support-files's folder CP to/ETC/MY.CNF

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.