Upgrade centos to the latest mysql

Source: Internet
Author: User

Download the mysql yum source from the website at the following address:
Http://repo.mysql.com/
Check the system version number on linux and download it based on the version number.
More/etc/redhat-release

Rpm-Uvh http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm

Yum-y upgrade mysql
Mysql_upgrade

Modify the character set of database, table, and column
# For each database:
Alter database vipmonk character set = utf8mb4 COLLATE = utf8mb4_unicode_ci;
# For each table:
Alter table table_name convert to character set utf8mb4 COLLATE utf8mb4_unicode_ci;
# For each column:
Alter table table_name CHANGE column_name VARCHAR (191) character set utf8mb4 COLLATE utf8mb4_unicode_ci;
# (Don't blindly copy-paste this! The exact statement depends on the column type, maximum length, and other properties. The above line is just an example for a 'varchar 'column .)

Modify my. ini (my. cnf in linux)
[Client]
Default-character-set = utf8mb4

[Mysql]
Default-character-set = utf8mb4

[Mysqld]
Character-set-client-handshake = FALSE
Character-set-server = utf8mb4
Collation-server = utf8mb4_unicode_ci
Init_connect = 'set NAMES utf8mb4'

Restart Mysql and check the character set:
Mysql> show variables where Variable_name LIKE 'character \ _ set \ _ % 'OR Variable_name LIKE 'colation % ';
+ -------------------------- + -------------------- +
| Variable_name | Value |
+ -------------------------- + -------------------- +
| Character_set_client | utf8mb4 |
| Character_set_connection | utf8mb4 |
| Character_set_database | utf8mb4 |
| Character_set_filesystem | binary |
| Character_set_results | utf8mb4 |
| Character_set_server | utf8mb4 |
| Character_set_system | utf8 |
| Collation_connection | utf8mb4_unicode_ci |
| Collation_database | utf8mb4_unicode_ci |
| Collation_server | utf8mb4_unicode_ci |
+ -------------------------- + -------------------- +
10 rows in set (0.00 sec)

Modify character sets for all tables and fields
Alter table tbl_name convert to character set character_name [COLLATE...] example:
Alter table logtest convert to character set utf8 COLLATE utf8_general_ci;

// Modify character sets of all tables and fields in batches
SELECT
CONCAT ('alter table', table_name, 'convert to character set utf8mb4 COLLATE utf8mb4_unicode_ci ;')
FROM
INFORMATION_SCHEMA.tables
WHERE
TABLE_SCHEMA = 'database _ name'

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.