首页 > 数据库 > mysql教程 > centos升级到最新的mysql_MySQL

centos升级到最新的mysql_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
发布: 2016-06-01 13:16:47
原创
899 人浏览过

CentOS

去网站下载mysql的yum源,地址如下:
http://repo.mysql.com/
在linux上先查看系统的版本号,根据版本号对应下载
more /etc/redhat-release

rpm -Uvhhttp://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm

yum -y upgrade mysql
mysql_upgrade

修改database,table,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 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.)

修改my.ini(linux下为my.cnf)
[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'

重新启动Mysql,检查字符集:
mysql> SHOW VARIABLES WHERE Variable_name LIKE 'character/_set/_%' OR Variable_name LIKE 'collation%';
+--------------------------+--------------------+
| 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)

修改所有表和字段的字符集
ALTER TABLE tbl_name CONVERT TO CHARACTER SET character_name [COLLATE ...] 如:
ALTER TABLE logtest CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;

//批量修改所有表和字段的字符集
SELECT
CONCAT('alter table ',table_name,' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;')
FROM
INFORMATION_SCHEMA.tables
WHERE
TABLE_SCHEMA='database_name'

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
centos7 - git的linux版本没有centos的?
来自于 1970-01-01 08:00:00
0
0
0
学习Linux的先行知识
来自于 1970-01-01 08:00:00
0
0
0
Linux下连接数据库
来自于 1970-01-01 08:00:00
0
0
0
Linux 批量修改文件名
来自于 1970-01-01 08:00:00
0
0
0
Linux中如何查看服务器的日志
来自于 1970-01-01 08:00:00
0
0
0
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板