1 登录
mysql -u username -ppassword(如 mysql -u root -p123456)
2 查看所有数据库名称
show databases;
3 创建数据库
create database test;
4 使用哪个数据库
use test; //使用此条命令后,即可在test数据库下进行操作;
5 创建表
use test;
creat table student(id int(11) NOT NULL AUTO_INCREMENT,
name varchar(32) DEFAULT NULL,
sex varchar(2) DEFAULT NULL,
PRIMARY KEY (id))DEFAULT CHARSET=utf8;
6 查询表数量和名称
use test;
show tables;
7 查看表属性
use test;
describe student;
8 插入数据
INSERT INTO student(id,name,sex) VALUES ( 1,'小明', '男');
9 遇到问题
出现'> 输入' 回车,再输入; 回车