Changing the character set encoding in Linux mysql and changing the default mysql encoding in ubuntu

Source: Internet
Author: User
Tags mysql tutorial

Changing the character set encoding in the Linux mysql tutorial and changing the default mysql encoding in ubuntu

Find the configuration file
/Etc/mysql/my. cnf
Add
Default-character-set = utf8
Add
Default-character-set = utf8
Restart the server
Service mysql restart
In mysql, type the following command:
Show variables like 'character _ set _ %'
The result is as follows:
Character_set_client utf8
Character_set_connection utf8
Character_set_database latin1
Character_set_filesystem binary
Character_set_results utf8

Change the default mysql encoding (character set) in ubuntu)


Install mysql
Sudo apt-get install mysql-server # automatically obtain available versions
You can also write it like this.
Sudo apt-get install mysql-server-5.0 # install mysql Server version 5.0
After installation
/Etc/init. d/mysql start (stop) is used to start and stop the server.
/Etc/mysql/main configuration file location my. cnf
/Var/lib/mysql/stores the database tutorial table folder. Here, mysql is equivalent to the date folder of mysql in windows.
After mysql is started, log on to mysql as the root user
Isher @ isher-ubuntu :~ $ Mysql-u root
> Show variables like 'character % '; # display the code
+ -------------------------- + ---------------------------- +
| 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/|
+ -------------------------- + ---------------------------- +
In some cases, we need to modify the encoding of the default mysql database to ensure that some migrated programs can be properly displayed. edit my. modify the cnf file encoding. For windows, you can directly use Mysql Server Instance Config Wizard to set
Modify one of the three my. cnf files in linux:/etc/mysql/my. cnf
Find the client configuration [client] and add it below
Default-character-set = utf8 default character set: utf8
Add in [mysqld]
Default-character-set = utf8 default character set: utf8
Init_connect = 'set NAMES utf8' (utf8 encoding is used to SET the connection to the mysql database to run utf8)
After modification, restart mysql and 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 the standard mysql version, for the/etc/my. cnf file, you need to copy from the mysql/support-files Folder cp my-large.cnf 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.