mysql -u root -p
create database 数据库名字
- mysql> create database yourdb;
- Query OK, 1 row affected (0.03 sec)
show databases;
实操结果如下
- mysql> show databases;
- +--------------------+
- | Database |
- +--------------------+
- | information_schema |
- | mysql |
- | performance_schema |
- | sys |
- +--------------------+
- 4 rows in set (0.01 sec)
use 数据库名
- mysql> use yourdb;
- Database changed
create table `表格名`(
`列字段名1` 变量类型 关键字,
`列字段名2` 变量类型 关键字,
`列字段名3` 变量类型 关键字
)DEFAULT CHARSET=utf8;
//其中关键字可以省略
- mysql> CREATE TABLE user(
- -> username char(50) NULL,
- -> passwd char(50) NULL
- -> )ENGINE=InnoDB;
- Query OK, 0 rows affected (0.06 sec)
insert into 表格名 values(值1, 值2,值3);
INSERT INTO user(username, passwd) VALUES('name', 'passwd');
quit;