您好,登錄后才能下訂單哦!
這篇文章給大家分享的是有關MySQL中如何修改默認引擎和字符集的內容。小編覺得挺實用的,因此分享給大家做個參考,一起跟隨小編過來看看吧。
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.打開配置文件
[root@VM_0_15_centos ~]# vim /etc/my.cnf
2.在最下面編輯如下內容:
default-storage-engine=InnoDB
3.重啟服務
[root@VM_0_15_centos ~]# systemctl restart mysqld
查看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 表名;
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中如何修改默認引擎和字符集”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,讓大家可以學到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。