show databases; #显示库(数据库)列表
mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | phpmyadmin | | reju | +--------------------+ 5 rows in set (0.00 sec)
create database db_name; #创建库
mysql> create database test; Query OK, 1 row affected (0.00 sec) mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | phpmyadmin | | reju | | test | +--------------------+ 6 rows in set (0.00 sec)
drop database db_name; #删除库
mysql> drop database test; Query OK, 0 rows affected (0.00 sec) mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | phpmyadmin | | reju | +--------------------+ 5 rows in set (0.00 sec)
use db_name; #选择(进入)指定库;等同于Linux的cd命令;利用命令select database();可查看当前所在库位置
mysql> use test; Database changed
mysql> select database(); +------------+ | database() | +------------+ | test | +------------+ 1 row in set (0.00 sec)