最近开始学习MySQL,主要是通过书籍,和看燕十八老师的视频,然后通过博客记录自己的学习过程。

登入

[email protected]:~$  -uroot -p
Enter password: 
查看当前所有数据库
mysql> show databases;#查看当前所有数据库
+--------------------+
| Database           |
+--------------------+
| information_schema |
| ceshi              |
| mysql              |
| performance_schema |
+--------------------+
4 rows in set (0.04 sec)
创建数据库ceshi1
mysql> create database ceshi1;#创建数据库ceshi1
Query OK, 1 row affected (0.00 sec)

mysql> show databases;#查看当前所有数据库,会看到现在多了一个ceshi1
+--------------------+
| Database           |
+--------------------+
| information_schema |
| ceshi              |
| ceshi1             |
| mysql              |
| performance_schema |
+--------------------+
5 rows in set (0.00 sec)
查看数据库ceshi1的定义
mysql> show create database ceshi1;#查看数据库ceshi1的定义
+----------+-------------------------------------------------------------------+
| Database | Create Database                                                   |
+----------+-------------------------------------------------------------------+
| ceshi1   | CREATE DATABASE `ceshi1` /*!40100 DEFAULT CHARACTER SET latin1 */ |
+----------+-------------------------------------------------------------------+
1 row in set (0.00 sec)
删除数据库ceshi1
mysql> drop database ceshi1;#删除数据库ceshi1
Query OK, 0 rows affected (0.07 sec)

mysql> show databases;#查看当前所有数据库,现在会发现ceshi1已经不存在了,因为已经删除了
+--------------------+
| Database           |
+--------------------+
| information_schema |
| ceshi              |
| mysql              |
| performance_schema |
+--------------------+
4 rows in set (0.00 sec)