Ubuntu installs MySQL and sets the character set to UTF-8

Source: Internet
Author: User

First, install the database

1. Get and install MySQL

sudo Install Mysql-server

2. Set the root password (enter the password in the pop-up prompt box)

3, log in the database, enter Mysql-u root-p, followed by the input password prompt, enter the password return can

$ mysql-u Root-penter passwordwelcome to the MySQL monitor.

4, check the database, enter show databases;

MySQL > show databases;

5. Display the current database

+--------------------+| Database           |+--------------------+| information_schema | | mysql              | | performance_schema |+--------------------+

Second, set character sets

1. Open the MySQL configuration file

sudo vim/etc/mysql/my.cnf

2, find [mysqld] below enter the code below, click ESC and enter: Wq Save exit

[Mysqld]init_connect='SET collation_connection = utf8_unicode_ci'init_ Connect='SET NAMES UTF8'character-set-server=utf8collation- server=Utf8_unicode_ciskip-character-set-client-handshake

3. Restart MySQL Service

$ service MySQL Restart

4. Enter Mysql-u root-p to re-enter MySQL

$ mysql-u root-penter password

5. Enter show variables like '%character% ' to view character set

' %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/|+--------------------------+----------------------------+

As you can see, the character set has been successfully changed to UTF-8 format

Ubuntu installs MySQL and sets the character set to UTF-8

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.