MySQL修改默认引擎和字符集详情

作者:markLogZhu 时间:2024-01-14 21:37:27 

目录
  • 一、数据库引擎

    • 1.1 查看数据库引擎

    • 1.2 修改默认数据库引擎

  • 二、数据库字符集

    • 2.1 查看字符集

    • 2.2 修改字符集

一、数据库引擎

1.1 查看数据库引擎


mysql> show engines;
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine             | Support | Comment                                                        | Transactions | XA   | Savepoints |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| InnoDB             | DEFAULT | Supports transactions, row-level locking, and foreign keys     | YES          | YES  | YES        |
| MRG_MYISAM         | YES     | Collection of identical MyISAM tables                          | NO           | NO   | NO         |
| MEMORY             | YES     | Hash based, stored in memory, useful for temporary tables      | NO           | NO   | NO         |
| BLACKHOLE          | YES     | /dev/null storage engine (anything you write to it disappears) | NO           | NO   | NO         |
| MyISAM             | YES     | MyISAM storage engine                                          | NO           | NO   | NO         |
| CSV                | YES     | CSV storage engine                                             | NO           | NO   | NO         |
| ARCHIVE            | YES     | Archive storage engine                                         | NO           | NO   | NO         |
| PERFORMANCE_SCHEMA | YES     | Performance Schema                                             | NO           | NO   | NO         |
| FEDERATED          | NO      | Federated MySQL storage engine                                 | NULL         | NULL | NULL       |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
9 rows in set (0.00 sec)

可以看到默认引擎是 InnoDB

1.2 修改默认数据库引擎

1.打开配置文件


[root@VM_0_15_centos ~]# vim /etc/my.cnf

2.在最下面编辑如下内容:


default-storage-engine=InnoDB

3.重启服务


[root@VM_0_15_centos ~]# systemctl restart mysqld

二、数据库字符集

2.1 查看字符集

查看MYSQL数据库服务器和数据库字符集


mysql> show variables like '%character%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | latin1                     |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | latin1                     |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.01 sec)

字符集作用
character_set_client用来设置客户端使用的字符集。
character_set_connection用来设置连接数据库时的字符集
character_set_database用来设置默认创建数据库的编码格式
character_set_filesystem文件系统的编码格式,把操作系统上的文件名转化成此字符集,默认binary是不做任何转换的
character_set_results查询结果字符集
character_set_server服务器安装时指定的默认编码格式
character_set_system系统元数据(字段名等)字符集
character_sets_dir字符集安装的目录

查看 MYSQL 所支持的字符集


show charset;

查看库的字符集


show database status from 库名 like  表名;

查看表的字符集


show table status from 库名 like  表名;

查看表中所有列的字符集


show full columns from 表名;

2.2 修改字符集

1.打开配置文件


[root@VM_0_15_centos ~]# vim /etc/my.cnf

2.在最下面编辑如下内容:


character-set-server=utf8
[client]
default-character-set=utf8

3.重启服务并验证


[root@VM_0_15_centos ~]# systemctl restart mysqld
[root@VM_0_15_centos ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.27 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 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/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)

来源:https://www.cnblogs.com/markLogZhu/p/11397931.html

标签:MySQL,修改默认引擎,修改字符集
0
投稿

猜你喜欢

  • vue+elementui+vuex+sessionStorage实现历史标签菜单的示例代码

    2024-04-30 10:26:30
  • numpy的文件存储.npy .npz 文件详解

    2023-02-08 17:16:35
  • python多线程分块读取文件

    2023-10-29 18:48:51
  • 将mysql转换到oracle必须了解的50件事

    2010-07-05 12:15:00
  • PyTorch 随机数生成占用 CPU 过高的解决方法

    2021-09-23 09:12:31
  • js实现简易垂直滚动条

    2024-05-22 10:34:53
  • Python基于checksum计算文件是否相同的方法

    2022-11-08 20:30:48
  • asp javascript值的互相传递方法

    2011-03-30 10:37:00
  • python执行get提交的方法

    2022-08-09 01:53:12
  • js删除数组中指定元素的几种方式

    2024-04-10 10:50:48
  • Python‘==‘ 及 ‘is‘相关原理解析

    2021-10-11 15:16:59
  • PHP实现的AES加密、解密封装类与用法示例

    2023-07-23 12:56:45
  • python moviepy 的用法入门篇

    2022-09-03 11:41:16
  • 代码详解Python的函数基础(1)

    2023-08-16 17:47:22
  • HTML5 第二份草案发布

    2008-06-17 17:42:00
  • 通过5个例子让你学会Pandas中的字符串过滤

    2022-10-09 03:44:36
  • 详解centos7+django+python3+mysql+阿里云部署项目全流程

    2024-01-24 15:10:54
  • python多进程执行方法apply_async使用说明

    2023-01-31 11:56:10
  • 讲解数据库加密技术的功能特性与实现方法

    2008-12-18 14:24:00
  • mysql-connector-java与mysql版本的对应关系说明

    2024-01-19 07:35:36
  • asp之家 网络编程 m.aspxhome.com