- 登录
mysql -u root -p root
- 查看版本
select version();
- 基本语句
show databases; -查看数据库
create database test; //新建数据库test
use test; //使用数据库
show tables; //查看表
create table admin(id int not null auto_increment,username varchar(100) not null,password varchar(100) not null,primary key(id)); //创建表
show full columns from admin; //查看字段类型
insert into admin(username,password) values("admin1","password1"); //插入数据
update tablename set username ='zhangsan' where id =5; //修改数据
delete from admin where id=1; //删除id=1这一行的数据
select * from admin; //查看数据
select * form admin where id=1;