MySQL修改默认引擎和字符集详情
程序员文章站
2022-06-19 10:58:22
目录一、数据库引擎1.1 查看数据库引擎mysql> show engines;+--------------------+---------+-------------------------...
一、数据库引擎
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)
到此这篇关于mysql修改默认引擎和字符集详情的文章就介绍到这了,更多相关mysql修改默认引擎和字符集内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!
上一篇: 夫妻闹别扭
下一篇: 谷歌透明度报告:全球*索要请求达历史新高