- OS : Ubuntu 18.04.1 LTS
- DBMS : mysql 8.0.12
示例
stu@Ubuntu:~$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 77
Server version: 8.0.12 MySQL Community Server - GPL
Copyright (c) 2000, 2018, 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 databases;
+--------------------+
| Database |
+--------------------+
| employees |
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.00 sec)
mysql> create database db_herbal_medicine;
Query OK, 1 row affected (0.03 sec)
mysql> show create database db_herbal_medicine;
+--------------------+-----------------------------------------------------------------------------------------------------------+
| Database | Create Database |
+--------------------+-----------------------------------------------------------------------------------------------------------+
| db_herbal_medicine | CREATE DATABASE `db_herbal_medicine` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci */ |
+--------------------+-----------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> alter database db_herbal_medicine charset=gbk collate=gbk_chinese_ci;
Query OK, 1 row affected (0.11 sec)
mysql> use db_herbal_medicine;
Database changed
mysql> show variables like'character%';
+--------------------------+--------------------------------+
| Variable_name | Value |
+--------------------------+--------------------------------+
| character_set_client | utf8mb4 |
| character_set_connection | utf8mb4 |
| character_set_database | gbk |
| character_set_filesystem | binary |
| character_set_results | utf8mb4 |
| character_set_server | utf8mb4 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql-8.0/charsets/ |
+--------------------------+--------------------------------+
8 rows in set (0.00 sec)
mysql> show variables like'collation%';
+----------------------+--------------------+
| Variable_name | Value |
+----------------------+--------------------+
| collation_connection | utf8mb4_0900_ai_ci |
| collation_database | gbk_chinese_ci |
| collation_server | utf8mb4_0900_ai_ci |
+----------------------+--------------------+
3 rows in set (0.00 sec)
mysql> exit
Bye
stu@Ubuntu:~$
学习资源
欢迎各位同学一起来交流学习心得!
最后修改时间:2021-12-16 18:04:04
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




