MySQL: Modify the default encoding

Source: Internet
Author: User

Take utf8 as an example. Assume that you have followed the instructions in my previous blog to install MySQL and the installation is successful.


1. Stop MySQL


Sudo/etc/init. d/MySQL. server stop


2. modify my. CNF


Sudo gedit/etc/My. CNF


Find the corresponding part and add the red part.


[Client]
# MARK add
Default-character-set = utf8

# Omitted

# The MySQL Server
[Mysqld]
# MARK add
Character_set_server = utf8
# MARK add
Init_connect = 'set names utf8'

# Omitted

3. Start MySQL


Sudo/etc/init. d/MySQL. Server start


4. Connect to MySQL


Mysql-u root-P


5. Check the encoding.


There are many methods, such as three examples (the following three images ).


A. Command Method




B. Assume that after the default encoding is changed, you have created the database mydb and table mytable


Note: mytable can be created in mydb only after mydb is used.




C. \ s or status;








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.