命令行下建立不同字符集的数据库、删除数据库:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
[root@lamp ~]# /usr/local/mysql/bin/mysql -uroot -p'admin123' Warning: Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.6.16 Source distribution Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. mysql> create database byrd_default; #建议一个叫做byrd_default的数据库 Query OK, 1 row affected (0.08 sec) mysql> show databases like 'byrd%'; #查看以byrd开头的数据库, +------------------+ | Database (byrd%) | +------------------+ | byrd_default | +------------------+ 1 row in set (0.00 sec) mysql> show create database byrd_default; #查看系统建立byrd_default命令,byrd_default默认编码是utf8,因为我编译mysql的时候设置的默认编码为utf8 +--------------+-----------------------------------------------------------------------+ | Database | Create Database | +--------------+-----------------------------------------------------------------------+ | byrd_default | CREATE DATABASE `byrd_default` /*!40100 DEFAULT CHARACTER SET utf8 */ | +--------------+-----------------------------------------------------------------------+ 1 row in set (0.00 sec) mysql> create database gbk default character set gbk collate gbk_chinese_ci; #建立一个名字叫做gbk,编码方式是gbk的数据库 Query OK, 1 row affected (0.00 sec) mysql> show create database gbk; +----------+-------------------------------------------------------------+ | Database | Create Database | +----------+-------------------------------------------------------------+ | gbk | CREATE DATABASE `gbk` /*!40100 DEFAULT CHARACTER SET gbk */ | +----------+-------------------------------------------------------------+ 1 row in set (0.00 sec) mysql> show databases; #所有数据库表 +--------------------+ | Database | +--------------------+ | information_schema | | byrd_default | | gbk | | gbk1 | | gbk2 | | gbk3 | | gbk4 | | mysql | | performance_schema | | test | | ultrax | +--------------------+ 11 rows in set (0.00 sec) mysql> drop database gbk1; #删除名字为gbk1的数据库 Query OK, 0 rows affected (0.19 sec) mysql> drop database gbk2; Query OK, 0 rows affected (0.00 sec) mysql> drop database gbk3; Query OK, 0 rows affected (0.00 sec) mysql> drop database gbk4; Query OK, 0 rows affected (0.01 sec) mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | byrd_default | | gbk | | mysql | | performance_schema | | test | | ultrax | +--------------------+ 7 rows in set (0.00 sec) mysql> drop database if exists byrd_default; #如果byrd_default的数据库存在则删除,如果不存在则提示警告 Query OK, 0 rows affected (0.00 sec) mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | gbk | | mysql | | performance_schema | | test | | ultrax | +--------------------+ 6 rows in set (0.00 sec) mysql> |
申明:本文由BYRD原创(基于Mysql5.6.16),未经许可禁止转载!
数据库权限参考:http://note.t4x.org/database/all-privileges-detailed/ SourceByrd's Weblog-https://note.t4x.org/database/create-drop-mysql-database/
申明:除非注明Byrd's Blog内容均为原创,未经许可禁止转载!详情请阅读版权申明!